当前位置: 首页>>代码示例>>Python>>正文


Python DBManager.updateNodeLocation方法代码示例

本文整理汇总了Python中DBManager.DBManager.updateNodeLocation方法的典型用法代码示例。如果您正苦于以下问题:Python DBManager.updateNodeLocation方法的具体用法?Python DBManager.updateNodeLocation怎么用?Python DBManager.updateNodeLocation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DBManager.DBManager的用法示例。


在下文中一共展示了DBManager.updateNodeLocation方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run

# 需要导入模块: from DBManager import DBManager [as 别名]
# 或者: from DBManager.DBManager import updateNodeLocation [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


注:本文中的DBManager.DBManager.updateNodeLocation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。