def run(self): # run until forced to stop while True: # block until a new alert object appears on the queue alert = self.queue.get() # if alert.contactID exists if alert.contactID is not None: # try to find the contact information for the alert object's contactID try: db = DBManager() contact = db.findContact(cID=alert.contactID) db.close() # send the alert using the provided communication types self.sendAlert(contact, alert) except ContactError as ce: self.logger.info( str(self.reporterID) + ": Contact with ID: %s was not found" % str(alert.contactID) )
print "\t(-) Failure of createContact Test Failed" except ContactError as ce: print "\t(+) Failure of createContact Test Passed. Error Caught:", ce.msg try: db.createContact(email=bademail) print "\t(-) Failure of createContact Test Failed" except ContactError as ce: print "\t(+) Failure of createContact Test Passed. Error Caught:", ce.msg try: db.createContact(sms=badsms) print "\t(-) Failure of createContact Test Failed" except ContactError as ce: print "\t(+) Failure of createContact Test Passed. Error Caught:", ce.msg #---------------------------------------------------------------------------------------------------------# print "(=) Testing findContact function" byID = db.findContact(cID=contID) if byID['cID'] == contID: print "\t(+) Found contact by cID" else: print "\t(-) Could not find contact by cID" #---------------------------------------------------------------------------------------------------------# byInfo = db.findContact(fName=cont1['fName'], lName=cont1['lName'], email=cont1['email'], sms=cont1['sms']) if byInfo['cID'] == contID: print "\t(+) Found contact by information" else: print "\t(-) Could not find contact by information" #---------------------------------------------------------------------------------------------------------# print "(=) Testing assignSession function" db.assignSession(ses, fName=cont1['fName'], lName=cont1['lName'], email=cont1['email'], sms=cont1['sms']) db.printSessions() db.unassignSession(ses)