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


Python DBManager.getNode方法代碼示例

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


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

示例1: run

# 需要導入模塊: from DBManager import DBManager [as 別名]
# 或者: from DBManager.DBManager import getNode [as 別名]
	def run(self):
		try:
			logMsg = 'Place holder for log message'
			#prepend parent ID to log message
			parentID = str(self.parentID)
			#connect to the database by constructing a DBManager object
			db = DBManager()
			#get devID from client
			devID = self.getChunk()		
			
			#check if node exists
			try:
				node = db.getNode(devID)
				nID = node['nID']
				
				#get the location time and data from the client
				locTime = self.getChunk()
				lat = self.getChunk()
				lon = self.getChunk()
				
				#update node location in nodes table regardless of whether it is active
				db.updateNodeLocation(nID, locTime, lat, lon)
				sessionTblName = node['session']
				if sessionTblName == None:
					logMsg = "(-) %s - Node is not active. Device ID: %s" % (parentID, devID)
				else:
					#write the location data to DB
					db.createLocation(sessionTblName, nID, locTime, lat, lon)
					logMsg = "(+) %s - Received data. Device ID: %s" % (parentID, devID)
			#if the node does not exist
			except NodeError:
				logMsg = "(-) %s - Device at %s not recognized. Device ID: %s" % (parentID, self.sockname, devID)
		# if client hangs up
		except (EOFError, socket.timeout):
			logMsg = "(-) %s - Client %s closed connection or timed-out" % (parentID, self.sockname)

		self.logger.info(logMsg)
		# print logMsg
		db.close()
		self.cSock.close()
開發者ID:haidark,項目名稱:rahat,代碼行數:42,代碼來源:Listener.py

示例2: update

# 需要導入模塊: from DBManager import DBManager [as 別名]
# 或者: from DBManager.DBManager import getNode [as 別名]
	def update(self):
		db = DBManager()
		nodeData = db.getNode(self.devID)		
		db.close()
		self.setLocals(nodeData)
開發者ID:haidark,項目名稱:rahat,代碼行數:7,代碼來源:NodeHandler.py


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