예제 #1
0
                # the medbook laptop can't phone home.
                raise

            code = response.getcode()
            if(code != httplib.OK):
                print "ERROR: bad http status code: %d" % code
                # continue to next message
                continue

            try:
                # Parse the body of the HTTP response
                # We get the same json object back, with the receipt field filled in
                json = response.read()
                msg2 = simplejson.loads(json)
                a = msg2['receipt']
                msg.receipt = a

                # If we got this far, we assume the incoming message has
                # been successfully sent to EC2
                msg.date_sent = datetime.now()

                msg.save()
            except:
                raise

        # Sleep
        time.sleep(options.polltime)


if(__name__ == "__main__"):
    sys.exit(main(sys.argv))