import sys import time sys.path.append("..") from settings import * from myparser import * from awssqs import awssqs q = awssqs(FRONTEND_INCOMING) time.sleep(2) def process(inxmltext): time.sleep(1) print inxmltext #parsa(inxmltext) q.write(inxmltext) #test ListCells for num in xrange(1,11): process(XML_Request(num,'ListCells', '201210230000','201210280000',num)) # XML_Request(ID,RequestType,TimeStart,TimeStop,CellID): #test CellStatSpeed #will probably produce some XML_CellIDError's for num in xrange(11,21): process(XML_Request(num,'CellStatSpeed', '201210230000','201210280000',num)) #test CellStatNet for num in xrange(21,31): process(XML_Request(num,'CellStatNet', '201210230000','201210280000',num)) #test error messages
import time import sys sys.path.append("..") from awssqs import awssqs msg = "test message" q = awssqs("testQ") time.sleep(10) try: q.write(msg) assert q.length() == 1, "Queue length not right" time.sleep(60) # Give it time to get the msg into the queue m = q.read() assert m != None, "m is None!" text = m.get_body() assert text == msg, "What we put in queue is not the same as came out!" assert q.read() == None, "Read should be locked!" q.delete(m) assert q.length() == 0, "Queue length not right" assert q.read() == None, "Queue should be empty" except Exception, e: print e finally: q.deleteQueue()
def getQ(self): if self.qin is None: self.qin = awssqs(FRONTEND_INCOMING) if self.connector is None: self.connector = Connector()
import sys import time sys.path.append("..") from settings import * from myparser import * from awssqs import awssqs q = awssqs(FRONTEND_INCOMING) time.sleep(2) def process(inxmltext): time.sleep(1) print inxmltext #parsa(inxmltext) q.write(inxmltext) #test ListCells for num in xrange(1, 11): process(XML_Request(num, 'ListCells', '201210230000', '201210280000', num)) # XML_Request(ID,RequestType,TimeStart,TimeStop,CellID): #test CellStatSpeed #will probably produce some XML_CellIDError's for num in xrange(11, 21): process( XML_Request(num, 'CellStatSpeed', '201210230000', '201210280000', num)) #test CellStatNet for num in xrange(21, 31):
#!/usr/bin/python import urllib2, time, sys sys.path.append("..") from awssqs import awssqs from settings import * # Global variables q = awssqs(FRONTEND_OUTGOING) fout = open("outgoing_results.xml", "a+b") while True: try: m = q.read() if m is not None: url = m.get_body() print "Url %s" % url f = urllib2.urlopen(url) data = f.read() print "MSG: %s" % data fout.write(data) q.delete(m) else: print "empty" break except Exception,e: print e time.sleep(10) fout.close()
#!/usr/bin/python import urllib2, time, sys sys.path.append("..") from awssqs import awssqs from settings import * # Global variables q = awssqs(FRONTEND_OUTGOING) fout = open("outgoing_results.xml", "a+b") while True: try: m = q.read() if m is not None: url = m.get_body() print "Url %s" % url f = urllib2.urlopen(url) data = f.read() print "MSG: %s" % data fout.write(data) q.delete(m) else: print "empty" break except Exception, e: print e time.sleep(10) fout.close()
except Exception, e: logger.error('Exception %s' % e) return "localhost" # Should never happen... if not os.path.exists(results): os.makedirs(results) db = None qIncoming = None qOutgoing = None c = 0 while True: try: if not qIncoming: qIncoming = awssqs(FRONTEND_INCOMING, 3600) if not qOutgoing: qOutgoing = awssqs(FRONTEND_OUTGOING) m = qIncoming.read() if m is None: # No job for me! print "no job" #time.sleep(INTERVALL) time.sleep(10) continue xmltext = m.get_body() if xmltext == "STOPINSTANCE": # Special case f = urllib2.urlopen(AMAZON_META_DATA_URL_INSTANCE_ID)