本文整理汇总了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