本文整理匯總了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