Showing posts with label python. Show all posts
Showing posts with label python. Show all posts

Thursday, July 9, 2009

Sending out email by python gaierror

I had to debug an instance of Plone that had an error to send out email today. First there was the whole problem with configuring sendmail to properly relay email. Finally I gave up, uninstalled sendmail and installed postfix.. :D Once I've verified the server can actually send email out, the problem still persist. It came to my mind that since the program (Plone) itself can send out email on other machines, it must be something else specific to that machine. Maybe python itself cannot send out email from that machine. So a quick google and I copied the code to send email out using python. It gave out the error more verbosely:

Traceback (most recent call last):
File "tryemail.py", line 24, in ?
server = smtplib.SMTP(SERVER)
File "/usr/lib/python2.4/smtplib.py", line 258, in __init__
addr = socket.gethostbyname(socket.gethostname())
socket.gaierror: (-2, 'Name or service not known')

Googling some more and I found this thread which basically says that python smtplib requires the hostname to be resolvable to send out email. So after some more googling (don't you just love google? :P) I found out how to change the hostname. So basically you need to change the HOSTNAME setting in /etc/sysconfig/network. But that requires a reboot. To avoid reboot just echo the hostname into /proc/sys/kernel/hostname. Finally. Now it's all done.. :)

Tuesday, June 16, 2009

Buildout with python2.4

I've got to write this down before I forget. With the newer distros, python 2.5 or 2.6 is the default python version of choice. But plone and zope currently still use python 2.4. And if you want buildout goodness you have to get buildout working with python 2.4. So if you're on ubuntu, first install these packages:

python2.4
python2.4-dev

And then google for ez_setup.py. Download it. Then run in your terminal:

abdullah@codebase:/$ sudo python2.4 ez_setup.py

That would install the 2.4 version of easy_install. Then to install buildout you just have to do like so:

abdullah@codebase:/$ sudo easy_install-2.4 zc.buildout

That would install buildout into your system. And then inside your plone or zope folder run:

abdullah@codebase:~/taskmanager$ buildout init

That would create a local instance of buildout for you to run specifically for your app. All eggs will be downloaded into that folder and would not pollute your system. To run the app specific buildout just do a :

abdullah@codebase:~/taskmanager$ bin/buildout -vvvv

That would run the local buildout. I just like it very very very very verbose.. :P

update: Sarogini found a link which deals with the problem of developing plone on ubuntu 9.04 in a more comprehensive manner here.

Sunday, May 25, 2008

Develop it FAST!!!

I've always liked game programming. That's what got me to start programming in the first place. But even with all the current advancement in technology and tools I've never actually got round to making one to the finish. While idly stumbling I've found this interesting article entitled "How To Build a Game In A Week From Scratch With No Budget". That Jay Barson must be one heck of a talented fella to be able to pull of what he did. Takes a lot of experience to be able to tell which way down the road you need to go when you've got to get there quick. Anyhow, what I liked best about the article is the lessons he learned after finally having done it:
  • Lesson 10: Doing something like this really was worthwhile
    • I know what he means when he says "You wouldn't think that working on Yet Another Game would feel like a vacation, but it did." Sometimes I feel I need to do that too. After a long stretch on one project, you just need a short sprint on a smaller one to just revitalize yourself.
  • Lesson 9: Cutting features isn't always free
    • Sometimes we think it's better to not do something in a more holistic way, we don't need THAT much bells and whistle. But in the end sometimes not doing it that way makes it so much harder to do even small things and things start to become repetitive and error prone REAL fast.
  • Lesson 8: Do the important stuff first
    • "If I pretend that I only have those 8 hours to 'finish' the game, what could I do that would make the biggest difference in those 8 hours?". That's a good way of thinking what do we really have to do to make it work. Probably should apply to most of my projects too.
  • Lesson 7: Scope will expand to exceed your budget and schedule
    • LOL.. I do this a LOT.. :D "Every programmer I've ever met tends to underestimate the time required for him or her to complete a feature.". Ask my manager, he'd know.. ;)
  • Lesson 6: Get the game playable as fast as possible
    • I know I've always tried to get my projects up as soon as possible so that the clients can give feedback as soon as possible. Sure you have a list of features to implement, but sometimes when all is dark, a lone beacon in the distance can make all the difference.
  • Lesson 5: It's sometimes much faster to throw away old code and start over
    • Ahhh.. one of those things that makes working in the software industry seems so volatile. You can work on a set of feature for a whole week to find that the way you should have implemented it is different and you just throw away the whole weeks' work. But actually it's never thrown away. It's hidden deep in your consciousness on how you should implement it the next time.
  • Lesson 4: Python Rules!
    • I couldn't agree more.. :D
  • Lesson 3: Don't underestimate the art requirements
    • Oh yeah.. so many times I've implemented so many killer features only to find customers looking at the unmade up interface and say "where's the value added in this???". Huh!! It doesn't matter you can do this and that, if it's ugly I don't want it. Sadly I'm not a full fledged graphic artist though.
  • Lesson 2: I need to be more efficient in my use of time
    • "Better use of my time means I can get more done AND have more 'free time' to do other things". Oh, how true.
  • Lesson 1: IT CAN BE DONE
    • Yeah... :D

Is Blogging No Longer a Thing?

As I embark on my new journey to learn the Rust programming language, I find myself pondering—where have all the blogs gone? In search of pr...