On 09/06/2012 09:49 AM, vi...@thepenguin.org wrote: > Thank you for your reply. I understand that it is odd, but my program is > being called from a hubot and returning data to it as well. I have figured > out how to make the changes to get it to output the correct data in the > correct format, but now I am getting a "Premature end of script headers" > error. I have the correct #! line and the output from the command line shows > no errors that would be interfering. Is there a way to make sure it is > showing me all the errors? To increase error logging? > ------ > !/usr/bin/env python
You top-posted, so I have to clip both the earlier messages out. On this forum, we put responses immediately AFTER the part we quoted. I don't see how I can possibly help further, without buying a hubot of my own. I don't know what operating system you're running this on, nor what the command lines look like. I have no idea how the stdout of your script migrates over to the hubot's processor. Nor why it only gets some of the stdout. You could give us more environmental data (OS version, command line, any messages, ...), or tell what the hubot's docs say you should use as a format. > import cloudfiles > import random > import sys > import array > > conn = cloudfiles.get_connection('username', 'key') > > containers = conn.get_all_containers() > i=0 > print "Content-type: text/html"; Perhaps you need a blank line to be output here. One way is just print by itself. > wholelist=containers[0].list_objects() > random.shuffle(wholelist) > newlist=[] > #newlist=wholelist[:] > try: > # print sys.argv[1] > if "=" in sys.argv[1]: sys.argv[1] = sys.argv[1].rstrip("=") > # print sys.argv[1] > del wholelist[int(sys.argv[1]):] > while i < int(sys.argv[1]): > newlist.append("http://example.com/"+wholelist[i].rstrip()) > i = i+1 > except IndexError, e: Where do you alert the user about this exception? > del newlist[5] > except Exception, err: > print 'Caught an exception' You should probably send this and any other error messages to stderr, as stdout is presumably being consumed by the robot. > print newlist, > ------- -- DaveA _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor