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


Python Manager.session_switch_status方法代码示例

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


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

示例1: Role

# 需要导入模块: from Manager import Manager [as 别名]
# 或者: from Manager.Manager import session_switch_status [as 别名]
class Role(AbstractRole):
	
	session_spooler = None
	
	@staticmethod
	def getName():
		return "Guest"
		
		
	def __init__(self, main_instance):
		
		AbstractRole.__init__(self, main_instance)
		Logger.info("Guest role::__init__")
		
		self.loop = True
		self.url = None
		self.host = Conf.hypervisor
		self.port = "1112"
		self.session = None
		self.session_spooler = multiprocessing.Queue()
		self.session_sync = multiprocessing.Queue()
		self.manager = Manager(self.main_instance.smRequestManager)
		self.session_manager = SessionManagement(self.manager, self.session_spooler, self.session_sync)
		self.current_session_status = None
		
		
	def init(self):
		Logger.info("Guest role::init")
		return True
	
	
	def launch(self):
		name = self.get_guest_name_from_hypervisor()
		
		Logger.debug("Role:: name : "+name)
				
		if name is False:
			return False
		
		self.write_name(name)
		
		self.send_couple_ip_nom()
		
		
	def order_stop(self):
		AbstractRole.order_stop(self)
		
		self.session_manager.looping = False
		self.loop = False
		
		
	def run(self):
		self.status = Role.STATUS_RUNNING
		self.launch()
		self.session_manager.start()
		Logger.info("Guest role::run begin")
		while self.loop:
			
			while True :
				try:
					session = self.session_sync.get(True,4)
				except Queue.Empty, e:
					break
				else:
					self.session = session
											
			if self.session is not None :
				ts_id = Util.getSessionID(self.session.user.name)
				
				if ts_id is not None :
					ts_status = Util.getState(ts_id)
					
					if ts_status == "logged" and self.current_session_status != "logged" :
						self.manager.session_switch_status(self.session, Session.SESSION_STATUS_ACTIVE)
						Logger.info("Role::SESSION LOGGED")
						self.current_session_status = ts_status
						continue
					
					if ts_status == "disconnected" and self.current_session_status != "disconnected" :
						self.manager.session_switch_status(self.session, Session.SESSION_STATUS_INACTIVE)
						Logger.info("Role::SESSION_DISCONNECTED")
						self.current_session_status = ts_status
						continue
					
				else :
					if self.current_session_status != "disconnected" and self.session.status != Session.SESSION_STATUS_INITED:
						self.manager.session_switch_status(self.session, Session.SESSION_STATUS_INACTIVE)
						Logger.info("Role::SESSION DISCONNECTED")
						self.current_session_status = "disconnected"
			
			time.sleep(2)
		
		Logger.info("Guest role::run end")
		self.status = Role.STATUS_STOP
开发者ID:bloveing,项目名称:openulteo,代码行数:96,代码来源:Role.py


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