def run(self): dbus_utils.LOOP_THREAD.start() oe.load_modules() oe.start_service() service_thread = Service_Thread() service_thread.start() while not self.abortRequested(): if self.waitForAbort(60): break if not oe.read_setting('bluetooth', 'standby'): continue timeout = oe.read_setting('bluetooth', 'idle_timeout') if not timeout: continue try: timeout = int(timeout) except: continue if timeout < 1: continue if xbmc.getGlobalIdleTime() / 60 >= timeout: log.log(f'Idle timeout reached', log.DEBUG) oe.standby_devices() if hasattr(oe, 'winOeMain') and hasattr(oe.winOeMain, 'visible'): if oe.winOeMain.visible == True: oe.winOeMain.close() oe.stop_service() service_thread.stop() dbus_utils.LOOP_THREAD.stop()
class cxbmcm(xbmc.Monitor): def __init__(self, *args, **kwargs): xbmc.Monitor.__init__(self) def onScreensaverActivated(self): oe.__oe__.dbg_log('c_xbmcm::onScreensaverActivated', 'enter_function', 0) if oe.__oe__.read_setting('bluetooth', 'standby'): threading.Thread(target=oe.__oe__.standby_devices).start() oe.__oe__.dbg_log('c_xbmcm::onScreensaverActivated', 'exit_function', 0) def onAbortRequested(self): pass xbmcm = cxbmcm() oe.load_modules() oe.start_service() monitor = service_thread(oe.__oe__) monitor.start() xbmcm.waitForAbort() if hasattr(oe, 'winOeMain'): if oe.winOeMain.visible == True: oe.winOeMain.close() oe.stop_service() monitor.stop()
if message == "exit": self.stopped = True self.oe.dbg_log("_service_::run", "exit_function", 0) except Exception, e: self.oe.dbg_log("_service_::run", "ERROR: (" + repr(e) + ")") # def onAbortRequested(self): # self.wait_evt.set() # def onScreensaverActivated(self): # self.wait_evt.set() oe.load_modules() oe.start_service() monitor = service_thread(oe.__oe__) monitor.start() while not xbmc.abortRequested: time.sleep(1) if hasattr(oe, "winOeMain"): if oe.winOeMain.visible == True: oe.winOeMain.close() oe.stop_service() monitor.stop()