當前位置: 首頁>>代碼示例>>Python>>正文


Python DBManager.findContact方法代碼示例

本文整理匯總了Python中DBManager.DBManager.findContact方法的典型用法代碼示例。如果您正苦於以下問題:Python DBManager.findContact方法的具體用法?Python DBManager.findContact怎麽用?Python DBManager.findContact使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在DBManager.DBManager的用法示例。


在下文中一共展示了DBManager.findContact方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: run

# 需要導入模塊: from DBManager import DBManager [as 別名]
# 或者: from DBManager.DBManager import findContact [as 別名]
 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)
                 )
開發者ID:haidark,項目名稱:rahat,代碼行數:20,代碼來源:Reporter.py

示例2:

# 需要導入模塊: from DBManager import DBManager [as 別名]
# 或者: from DBManager.DBManager import findContact [as 別名]
		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)
開發者ID:haidark,項目名稱:rahat,代碼行數:33,代碼來源:managerTest.py


注:本文中的DBManager.DBManager.findContact方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。