def _daemon(self): log('daemon started') if not os.path.isfile('/walkthrough_completed'): for module in self.stored_gui.live_modules: if 'id' in module: if module['id'] == "script.module.osmcsetting.networking": networking_instance = module['SET'] walkthru.open_gui(networking_instance) with open('/tmp/walkthrough_completed', 'w+') as f: pass subprocess.call(['sudo', 'mv', '/tmp/walkthrough_completed', '/walkthrough_completed']) WINDOW.clearProperty('walkthrough_is_running') xbmc.executebuiltin('ReloadSkin()') break else: log('Networking module not found') while True: # Check the current skin directory, if it is different to the previous one, then # recreate the gui. This is required because reference in the gui left in memory # do not survive a refresh of the skins textures (???) if self.skindir != xbmc.getSkinDir(): log('Old Skin: %s' % self.skindir) self.skindir = xbmc.getSkinDir() log('New Skin: %s' % self.skindir) try: resp = ubiquifonts.import_osmc_fonts() log('Ubiquifonts result: %s' % resp) if resp == 'reload_please': while True: xbmc.sleep(1000) xml = xbmc.getInfoLabel('Window.Property(xmlfile)') if xml not in ['DialogYesNo.xml', 'Dialogyesno.xml', 'DialogYesno.xml', 'DialogyesNo.xml', 'dialogyesno.xml']: log('Skin reload requested') xbmc.executebuiltin('ReloadSkin()') break except Exception as e: log(traceback.format_exc()) try: log('skin changed, reloading gui') del self.stored_gui except: pass self.create_gui() # if xbmc is aborting if self.monitor.waitForAbort(1): self.exit() break if not self.parent_queue.empty(): response = self.parent_queue.get() log('response : %s' % response) self.parent_queue.task_done() if response == 'open': try: del self.stored_gui # TESTING: this will mean that the gui is populated and loaded every time it opens except: pass self.open_gui() elif response == 'refresh_gui': ''' This may need to be moved to a separate thread, so that it doesnt hold up the other functions. ''' # if the gui calls for its own refresh, then delete the existing one and open a new instance # del self.stored_gui self.open_gui() elif response == 'exit': self.exit() break elif response == 'walkthru': for module in self.stored_gui.live_modules: if 'id' in module: log(module['id']) if module['id'] == "script.module.osmcsetting.networking": networking_instance = module['SET'] walkthru.open_gui(networking_instance) break else: log('Networking module not found') elif 'new_device:' in response: # a usb device is attached to the hardware # get the device id device_id = response[len('new_device:'):] # proceed only if the device_id is not null if device_id: # get ignore list ignore_list_raw = __setting__('ignored_devices') ignore_list = ignore_list_raw.split('|') # get sources list media_string = self.get_sources_list() # post dialogs to ask the user if they want to add the source, or ignore the device if device_id not in ignore_list and device_id not in media_string: d1 = DIALOG.yesno(lang(32002), lang(32003),lang(32004)) if d1: xbmc.executebuiltin("ActivateWindow(mediasource)") else: d2 = DIALOG.yesno(lang(32002), lang(32005)) if d2: ignore_list.append(str(device_id)) ignore_string = '|'.join(ignore_list) __addon__.setSetting('ignored_devices', ignore_string) # THIS PART MAY NOT BE NEEDED, BUT IS INCLUDED HERE ANYWAY FOR TESTING PURPOSES # if the gui was last accessed more than four hours if not self.skip_check and (datetime.datetime.now() - self.gui_last_accessed).total_seconds() > 14400: self.skip_check = True del self.stored_gui log('_daemon exiting')
def _daemon(self): log('daemon started') if not os.path.isfile('/walkthrough_completed'): for module in self.stored_gui.live_modules: if 'id' in module: if module['id'] == "script.module.osmcsetting.networking": networking_instance = module['SET'] vendor = check_vendor() walkthru.open_gui(networking_instance) log("Vendor is %s" % vendor) with open('/tmp/walkthrough_completed', 'w+') as f: log('/tmp/walkthrough_completed written') pass subprocess.call([ 'sudo', 'mv', '/tmp/walkthrough_completed', '/walkthrough_completed' ]) xbmc.setosmcwalkthroughstatus(2) WINDOW.clearProperty('walkthrough_is_running') xbmc.executebuiltin('ReloadSkin()') log('Skin reloaded') # @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ # Query user about whether they would like to update now update_check_now = False if vendor == 'noobs': update_check_now = DIALOG.yesno( lang(32026), lang(32027), lang(32028), lang(32029)) elif vendor == 'ts': update_check_now = DIALOG.yesno( lang(32026), lang(32030), lang(32031), lang(32029)) if update_check_now: log('User elected to update now') try: address = '/var/tmp/osmc.settings.update.sockfile' message = ('settings_command', { 'action': 'update' }) message = json.dumps(message) sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) sock.connect(address) sock.sendall(message) sock.close() except Exception as e: log(traceback.format_exc()) # @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ break else: log('Networking module not found') while True: # Check the current skin directory, if it is different to the previous one, then # recreate the gui. This is required because reference in the gui left in memory # do not survive a refresh of the skins textures (???) if self.skindir != xbmc.getSkinDir(): log('Old Skin: %s' % self.skindir) self.skindir = xbmc.getSkinDir() log('New Skin: %s' % self.skindir) try: resp = ubiquifonts.import_osmc_fonts() log('Ubiquifonts result: %s' % resp) if resp == 'reload_please': while True: xbmc.sleep(1000) xml = xbmc.getInfoLabel('Window.Property(xmlfile)') if xml not in [ 'DialogYesNo.xml', 'Dialogyesno.xml', 'DialogYesno.xml', 'DialogyesNo.xml', 'dialogyesno.xml' ]: log('Skin reload requested') xbmc.executebuiltin('ReloadSkin()') break except Exception as e: log(traceback.format_exc()) try: log('skin changed, reloading gui') del self.stored_gui except: pass self.create_gui() # if xbmc is aborting if self.monitor.waitForAbort(1): self.exit() break if not self.parent_queue.empty(): response = self.parent_queue.get() log('response : %s' % response) self.parent_queue.task_done() if response == 'open': try: del self.stored_gui # TESTING: this will mean that the gui is populated and loaded every time it opens except: pass self.open_gui() elif response == 'refresh_gui': ''' This may need to be moved to a separate thread, so that it doesnt hold up the other functions. ''' # if the gui calls for its own refresh, then delete the existing one and open a new instance # del self.stored_gui self.open_gui() elif response == 'exit': self.exit() break elif response == 'walkthru': for module in self.stored_gui.live_modules: if 'id' in module: log(module['id']) if module[ 'id'] == "script.module.osmcsetting.networking": networking_instance = module['SET'] walkthru.open_gui(networking_instance) break else: log('Networking module not found') elif 'new_device:' in response: # a usb device is attached to the hardware # get the device id device_id = response[len('new_device:'):] # proceed only if the device_id is not null if device_id: # get ignore list ignore_list_raw = __setting__('ignored_devices') ignore_list = ignore_list_raw.split('|') # get sources list media_string = self.get_sources_list() # post dialogs to ask the user if they want to add the source, or ignore the device if device_id not in ignore_list and device_id not in media_string: d1 = DIALOG.yesno(lang(32002), lang(32003), lang(32004)) if d1: xbmc.executebuiltin( "ActivateWindow(mediasource)") else: d2 = DIALOG.yesno(lang(32002), lang(32005)) if d2: ignore_list.append(str(device_id)) ignore_string = '|'.join(ignore_list) __addon__.setSetting( 'ignored_devices', ignore_string) else: # check whether the response is one of the live_modules, if it is then launch that module for module in self.stored_gui.live_modules: if response == module.get('id', 'id_not_found'): instance = module.get('SET', False) if instance.isAlive(): log('Opening %s from widget' % instance) instance.run() else: log('Starting %s from widget' % instance) setting_instance = module[ 'OSMCSetting'].OSMCSettingClass() setting_instance.setDaemon(True) module['SET'] = setting_instance setting_instance.start() # THIS PART MAY NOT BE NEEDED, BUT IS INCLUDED HERE ANYWAY FOR TESTING PURPOSES # if the gui was last accessed more than four hours if not self.skip_check and ( datetime.datetime.now() - self.gui_last_accessed).total_seconds() > 14400: self.skip_check = True del self.stored_gui log('_daemon exiting')
def _daemon(self): log('daemon started') if not os.path.isfile('/walkthrough_completed'): for module in self.stored_gui.live_modules: if 'id' in module: if module['id'] == "script.module.osmcsetting.networking": networking_instance = module['SET'] vendor = check_vendor() walkthru.open_gui(networking_instance) log("Vendor is %s" % vendor) with open('/tmp/walkthrough_completed', 'w+') as f: log('/tmp/walkthrough_completed written') pass subprocess.call(['sudo', 'mv', '/tmp/walkthrough_completed', '/walkthrough_completed']) xbmc.setosmcwalkthroughstatus(2) WINDOW.clearProperty('walkthrough_is_running') xbmc.executebuiltin('ReloadSkin()') log('Skin reloaded') # @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ # Query user about whether they would like to update now update_check_now = False if vendor == 'noobs': update_check_now = DIALOG.yesno(lang(32026), lang(32027), lang(32028), lang(32029)) elif vendor == 'ts': update_check_now = DIALOG.yesno(lang(32026), lang(32030), lang(32031), lang(32029)) if update_check_now: log('User elected to update now') try: address = '/var/tmp/osmc.settings.update.sockfile' message = ('settings_command', {'action': 'update'}) message = json.dumps(message) sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) sock.connect(address) sock.sendall(message) sock.close() except Exception as e: log(traceback.format_exc()) # @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ break else: log('Networking module not found') while True: # Check the current skin directory, if it is different to the previous one, then # recreate the gui. This is required because reference in the gui left in memory # do not survive a refresh of the skins textures (???) if self.skindir != xbmc.getSkinDir(): log('Old Skin: %s' % self.skindir) self.skindir = xbmc.getSkinDir() log('New Skin: %s' % self.skindir) try: resp = ubiquifonts.import_osmc_fonts() log('Ubiquifonts result: %s' % resp) if resp == 'reload_please': while True: xbmc.sleep(1000) xml = xbmc.getInfoLabel('Window.Property(xmlfile)') if xml not in ['DialogYesNo.xml', 'Dialogyesno.xml', 'DialogYesno.xml', 'DialogyesNo.xml', 'dialogyesno.xml']: log('Skin reload requested') xbmc.executebuiltin('ReloadSkin()') break except Exception as e: log(traceback.format_exc()) try: log('skin changed, reloading gui') del self.stored_gui except: pass self.create_gui() # if xbmc is aborting if self.monitor.waitForAbort(1): self.exit() break if not self.parent_queue.empty(): response = self.parent_queue.get() log('response : %s' % response) self.parent_queue.task_done() if response == 'open': try: del self.stored_gui # TESTING: this will mean that the gui is populated and loaded every time it opens except: pass self.open_gui() elif response == 'refresh_gui': ''' This may need to be moved to a separate thread, so that it doesnt hold up the other functions. ''' # if the gui calls for its own refresh, then delete the existing one and open a new instance # del self.stored_gui self.open_gui() elif response == 'exit': self.exit() break elif response == 'walkthru': for module in self.stored_gui.live_modules: if 'id' in module: log(module['id']) if module['id'] == "script.module.osmcsetting.networking": networking_instance = module['SET'] walkthru.open_gui(networking_instance) break else: log('Networking module not found') elif 'new_device:' in response: # a usb device is attached to the hardware # get the device id device_id = response[len('new_device:'):] # proceed only if the device_id is not null if device_id: # get ignore list ignore_list_raw = __setting__('ignored_devices') ignore_list = ignore_list_raw.split('|') # get sources list media_string = self.get_sources_list() # post dialogs to ask the user if they want to add the source, or ignore the device if device_id not in ignore_list and device_id not in media_string: d1 = DIALOG.yesno(lang(32002), lang(32003),lang(32004)) if d1: xbmc.executebuiltin("ActivateWindow(mediasource)") else: d2 = DIALOG.yesno(lang(32002), lang(32005)) if d2: ignore_list.append(str(device_id)) ignore_string = '|'.join(ignore_list) __addon__.setSetting('ignored_devices', ignore_string) else: # check whether the response is one of the live_modules, if it is then launch that module for module in self.stored_gui.live_modules: if response == module.get('id', 'id_not_found'): instance = module.get('SET', False) if instance.isAlive(): log('Opening %s from widget' % instance) instance.run() else: log('Starting %s from widget' % instance) setting_instance = module['OSMCSetting'].OSMCSettingClass() setting_instance.setDaemon(True) module['SET'] = setting_instance setting_instance.start() # THIS PART MAY NOT BE NEEDED, BUT IS INCLUDED HERE ANYWAY FOR TESTING PURPOSES # if the gui was last accessed more than four hours if not self.skip_check and (datetime.datetime.now() - self.gui_last_accessed).total_seconds() > 14400: self.skip_check = True del self.stored_gui log('_daemon exiting')
def _daemon(self): log('daemon started') if not os.path.isfile('/walkthrough_completed'): for module in self.stored_gui.live_modules: if 'id' in module: if module['id'] == "script.module.osmcsetting.networking": networking_instance = module['SET'] walkthru.open_gui(networking_instance) with open('/tmp/walkthrough_completed', 'w+') as f: pass subprocess.call([ 'sudo', 'mv', '/tmp/walkthrough_completed', '/walkthrough_completed' ]) WINDOW.clearProperty('walkthrough_is_running') xbmc.executebuiltin('ReloadSkin()') break else: log('Networking module not found') while True: # Check the current skin directory, if it is different to the previous one, then # recreate the gui. This is required because reference in the gui left in memory # do not survive a refresh of the skins textures (???) if self.skindir != xbmc.getSkinDir(): log('Old Skin: %s' % self.skindir) self.skindir = xbmc.getSkinDir() log('New Skin: %s' % self.skindir) try: resp = ubiquifonts.import_osmc_fonts() log('Ubiquifonts result: %s' % resp) if resp == 'reload_please': while True: xbmc.sleep(1000) xml = xbmc.getInfoLabel('Window.Property(xmlfile)') if xml not in [ 'DialogYesNo.xml', 'Dialogyesno.xml', 'DialogYesno.xml', 'DialogyesNo.xml', 'dialogyesno.xml' ]: log('Skin reload requested') xbmc.executebuiltin('ReloadSkin()') break except Exception as e: log(traceback.format_exc()) try: log('skin changed, reloading gui') del self.stored_gui except: pass self.create_gui() # if xbmc is aborting if self.monitor.waitForAbort(1): self.exit() break if not self.parent_queue.empty(): response = self.parent_queue.get() log('response : %s' % response) self.parent_queue.task_done() if response == 'open': try: del self.stored_gui # TESTING: this will mean that the gui is populated and loaded every time it opens except: pass self.open_gui() elif response == 'refresh_gui': ''' This may need to be moved to a separate thread, so that it doesnt hold up the other functions. ''' # if the gui calls for its own refresh, then delete the existing one and open a new instance # del self.stored_gui self.open_gui() elif response == 'exit': self.exit() break elif response == 'walkthru': for module in self.stored_gui.live_modules: if 'id' in module: log(module['id']) if module[ 'id'] == "script.module.osmcsetting.networking": networking_instance = module['SET'] walkthru.open_gui(networking_instance) break else: log('Networking module not found') elif 'new_device:' in response: # a usb device is attached to the hardware # get the device id device_id = response[len('new_device:'):] # proceed only if the device_id is not null if device_id: # get ignore list ignore_list_raw = __setting__('ignored_devices') ignore_list = ignore_list_raw.split('|') # get sources list media_string = self.get_sources_list() # post dialogs to ask the user if they want to add the source, or ignore the device if device_id not in ignore_list and device_id not in media_string: d1 = DIALOG.yesno(lang(32002), lang(32003), lang(32004)) if d1: xbmc.executebuiltin( "ActivateWindow(mediasource)") else: d2 = DIALOG.yesno(lang(32002), lang(32005)) if d2: ignore_list.append(str(device_id)) ignore_string = '|'.join(ignore_list) __addon__.setSetting( 'ignored_devices', ignore_string) # THIS PART MAY NOT BE NEEDED, BUT IS INCLUDED HERE ANYWAY FOR TESTING PURPOSES # if the gui was last accessed more than four hours if not self.skip_check and ( datetime.datetime.now() - self.gui_last_accessed).total_seconds() > 14400: self.skip_check = True del self.stored_gui log('_daemon exiting')