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


Python DBManager.deleteSession方法代码示例

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


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

示例1: run

# 需要导入模块: from DBManager import DBManager [as 别名]
# 或者: from DBManager.DBManager import deleteSession [as 别名]
	def run(self):	
		#Main SessionHandler loop (runs while session is active)
		while self.SessionActive():
			#update local members from session table row
			self.update()
			#instantiate a NodeHandler object for each node in the session handled
			#subsequent calls will not create duplicates
			self.createNodes()
			#start the NodeHandler housekeeping threads
			#but first check if they have already been started
			for node in self.nodes:
				#if not started
				if not self.nodesDict[node.devID] :
					#start the thread
					node.start()
					#ensure start is not called again
					self.nodesDict[node.devID] = True

			self.NodesHealthAlert()
			#TODO write a function to relate nodes and check relations
			#how often do we want to repeat this? do not want to put too much strain on the DB
			#should check report times every minute or so
			sleep(2*60)
		
		# # # # # # After Session Expires # # # # # # 
		
		#---signal to stop to all housekeeping threads
		#tell the threads to stop
		for node in self.nodes:			
			self.logger.info(self.phrase+": signalling node:"+node.devID+" to stop running")
			node.keepRunning = False
		#wait for the threads to finish their work
		for node in self.nodes:				
			if node.is_alive():
				node.join()
				self.logger.info(self.phrase+": node:"+node.devID+" thread stopped")
		
		#---check if all nodes have been returned		
		# initialize list of unreturned nodes: using list comprehension
		unreturnedNodes = [node for node in self.nodes if not node.returned()]	
		# fire off an alert for every node that has not been returned
		for unreturnedNode in unreturnedNodes:
			#fire off an alerts to let session leader and node holder know this node has not been returned
			title = "Unreturned Node"
			message =  unreturnedNode.devID+" has not been returned."
			#create an alert for the session leader
			sessionAlert = Alert(self.contactID, message, title)
			self.queue.put(sessionAlert)
			#create an alert for the unreturned node holder
			nodeAlert = Alert(unreturnedNode.contactID, message, title)
			self.queue.put(nodeAlert)
		
		# now loop until all nodes are returned
		while unreturnedNodes:
			#check if any nodes have been returned
			unreturnedNodes = [node for node in unreturnedNodes if not node.returned()]
			#delay before checking again?
			sleep(5*60)

		# after all nodes are returned, archive the session table and delete its row from the database
		db = DBManager()
		db.deleteSession(self.phrase)
		db.close()
开发者ID:haidark,项目名称:rahat,代码行数:65,代码来源:SessionHandler.py

示例2: DBManager

# 需要导入模块: from DBManager import DBManager [as 别名]
# 或者: from DBManager.DBManager import deleteSession [as 别名]
parser.add_argument("-S", "--SESSIONS", help="list all active sessions", action="store_true")
#-N to list all nodes and include [SESSIONNAME] to list all nodes in a session
parser.add_argument("-N", "--NODES", help="list all nodes in a session, use 0 for a list of all nodes", metavar='passphrase')

args = parser.parse_args()

db = DBManager()

if args.session != None:
	#create a new session
	db.createSession(args.session[0], int(args.session[1]))
	print "Created session with passphrase: " + args.session[0] + " for " + args.session[1] + " days"
	
elif args.archive != None:
	#archive session
	db.deleteSession(args.archive)
	print "Deleted session with passphrase: " + args.archive
	
elif args.node != None:
	#create a new node
	db.createNode(args.node)

	print "Created node with device ID: " + args.node
	
elif args.delete != None:
	#delete a node
	db.deleteNode(args.delete)
	print "Deleted node with device ID: " + args.delete
	
elif args.activate != None:
	#activate a node
开发者ID:haidark,项目名称:rahat,代码行数:33,代码来源:managerTest.py


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