def sendSms(payload, log): try: if 'sentinel' in payload: d = payload['sentinel'] updateAction(d['ID'], d['Action']) print "Finished with job: ", d['ID'] else: values = {'user' : 'WADI.COM', 'passwd' : 'SMS#WADI', 'DR':'Y','Sid':'Jlabs'} values.update(payload) url = config['sms_post_url'] data = urllib.urlencode(values) request = urllib2.Request(url, data) print "Got payload: ", payload wp = urllib2.urlopen(request) res = wp.read() print res if 'OK' in res: log('success') else: log('failure') return True except AssertionError: log('error') return False except Exception, e: log('error') print " >>> Error: "+str(e) return False
def callback(ch, method, prop, body): data = json.loads(body) payload = data[1] print "Got sms: "+str(payload) if 'sentinel' in payload: d = payload['sentinel'] updateAction(d['ID'], d['Action']) print "Finished with job: ", d['ID'] else: log(data[0])("success") ch.basic_ack(delivery_tag=method.delivery_tag)
def callback(ch, method, prop, body): data = json.loads(body) payload = data[1] print "Got sms: " + str(payload) if 'sentinel' in payload: d = payload['sentinel'] updateAction(d['id'], d['action'], d.get('oid')) print "Finished with job: ", d['id'] else: log(data[0])("success") ch.basic_ack(delivery_tag=method.delivery_tag)