def __init__(self, config_file): super(CTMain, self).__init__() set_log_level(LogLevel.DEBUG) self.config_service = ConfigService(config_file) self.timer_service = TimerService(self, self.config_service) self.ui_service = UIService(UI_TIMEOUT, self.config_service.password)
def __createServices(self): self.__services[TIMER_SERVICE] = TimerService() self.__services['ClientArena'] = ClientArena() self.__services['HUD'] = gui.hud.HUD() self.__services['Input'] = InputController() self.__services['Camera'] = Camera() self.__services['ClientStatsCollector'] = ClientStatsCollector() self.__services['ClientEconomics'] = ClientEconomic() self.__services['Chat'] = Chat() self.__services['BattleHints'] = Messenger(self) self.__services['GamePlayHints'] = GamePlayHints() if consts.IS_DEBUG_IMPORTED: from debug.AvatarDebug import AvatarDebugService self.__services['DebugHUD'] = AvatarDebugService()
def getTimerService(context): """ returns the SMTP srevice instance """ root = context.getPhysicalRoot() try: timer_service = getattr(root, cp_id) except AttributeError: try: control_panel = root.Control_Panel timer_service = getattr(control_panel, cp_id) except AttributeError: timer_service = TimerService(cp_id) else: control_panel._delObject(cp_id) root._setObject(cp_id, timer_service) return timer_service
class CTMain(object): def __init__(self, config_file): super(CTMain, self).__init__() set_log_level(LogLevel.DEBUG) self.config_service = ConfigService(config_file) self.timer_service = TimerService(self, self.config_service) self.ui_service = UIService(UI_TIMEOUT, self.config_service.password) #self.session_service = SessionService(self) #self.input_service = InputService(self) def start(self): # initially we're running but not counting self.timer_service.pause() self.timer_service.start() #self.session_service.start() #self.input_service.start() while True: try: sleep(1) except KeyboardInterrupt: info ("\nStopping!") self.timer_service.stop() break def timer_alert(self): info ("timer alert!") result = self.ui_service.get_input() if Results.TIMEOUT == result: info ("timeout") elif Results.SHUTDOWN == result: info ("shutdown") else: ext = datetime.now().replace(hour=0, minute=result, second=0, microsecond=0) self.timer_service.extension = ext self.timer_service.activate_alerts() def login(self): info ("login!") self.timer_service.resume() def logout(self): info ("logout!") self.timer_service.pause() def inactive(self): info ("inactive!") self.timer_service.pause() def active(self): info ("active!") self.timer_service.resume()