def __init__(self): self.first_run = True # the time that the service started self.service_start = datetime.now() # dictionary containing the permissable actions (communicated from the child apt scripts) # and the corresponding methods in the parent self.action_dict = { 'apt_cache update complete': self.apt_update_complete, 'apt_cache commit complete': self.apt_commit_complete, 'apt_cache fetch complete': self.apt_fetch_complete, 'progress_bar': self.progress_bar, 'update_settings': self.update_settings, 'update_now': self.update_now, 'user_update_now': self.user_update_now, 'kill_yourself': self.kill_yourself, 'settings_command': self.settings_command, 'apt_error': self.apt_error, 'action_list': self.action_list, 'apt_cache action_list complete': self.action_list_complete, } # queue for communication with the comm and Main self.parent_queue = Queue.Queue() self.randomid = random.randint(0, 1000) self.EXTERNAL_UPDATE_REQUIRED = 0 # create socket, listen for comms self.listener = comms.communicator( self.parent_queue, socket_file='/var/tmp/osmc.settings.update.sockfile') self.listener.start() # grab the settings, saves them into a dict called seld.s self.update_settings() # a class to handle scheduling update checks self.scheduler = sched.SimpleScheduler(self.s) log(self.scheduler.trigger_time, 'trigger_time') # this holding pattern holds a function that represents the completion of a process that was put on hold # while the user was watching media or the system was active self.function_holding_pattern = False # monitor for identifying addon settings updates and kodi abort requests self.monitor = Monitah(parent_queue=self.parent_queue) # window onto which to paste the update notification self.window = xbmcgui.Window(10000) # property which determines whether the notification should be pasted to the window self.window.setProperty('OSMC_notification', 'false') # ControlImage(x, y, width, height, filename[, aspectRatio, colorDiffuse]) self.update_image = xbmcgui.ControlImage(15, 55, 175, 75, __image_file__) self.position_icon() self.window.addControl(self.update_image) self.update_image.setVisibleCondition( '[SubString(Window(Home).Property(OSMC_notification), true, left)]' ) # this flag is present when updates have been downloaded but the user wants to choose when to install using # the manual control in the settings self.block_update_file = '/var/tmp/.suppress_osmc_update_checks' # if the file is present, then suppress further update checks and show the notification if os.path.isfile(self.block_update_file): self.skip_update_check = True # if the user has suppressed icon notification of updates and has chosen not to install the updates # its their own damned fault if osmc never get updated if not self.s['suppress_icon']: self.window.setProperty('OSMC_notification', 'true') else: self.skip_update_check = False # check for the external update failed fail_check_file = '/var/tmp/.osmc_failed_update' if os.path.isfile(fail_check_file): with open(fail_check_file, 'r') as f: package = f.readline() ok = DIALOG.ok(lang(32087), lang(32088) % package, '', lang(32089)) try: os.remove(fail_check_file) except: pass # a preliminary check for updates (for testing only) if self.s['check_onboot']: if not self.skip_update_check: self.boot_delay_passed = False self.function_holding_pattern = self.holding_pattern_boot_update log('boot update check put into holding pattern') # keep alive method self._daemon()
def update_settings(self): ''' Updates the settings for the service while the service is still running ''' if self.first_run: ''' Construct the settings dicionary ''' self.first_run = False self.scheduler_settings = ['check_freq', 'check_weekday', 'check_day', 'check_time', 'check_hour', 'check_minute'] self.icon_settings = ['pos_x', 'pos_y'] self.on_upd = [lang(x) for x in [32057,32058,32095,32060,32061]] # self.on_upd = [lang(x) for x in [32059,32061]] # 2==> 0, 4 ==> 1 self.s = {} self.s['on_upd_detected'] = int( __setting__('on_upd_detected') ) # this is to deprecate the automatic installation of non-system updates # changed to Download, and Prompt if self.s['on_upd_detected'] == 4: __addon__.setSetting('on_upd_detected', '2') self.s['on_upd_detected'] = 2 self.s['check_freq'] = int( __setting__('check_freq') ) self.s['check_weekday'] = int(float( __setting__('check_weekday') )) self.s['check_day'] = int(float( __setting__('check_day') )) self.s['check_time'] = int(float( __setting__('check_time') )) self.s['check_hour'] = int(float( __setting__('check_hour') )) self.s['check_minute'] = int(float( __setting__('check_minute') )) self.s['pos_x'] = int(float( __setting__('pos_x') )) self.s['pos_y'] = int(float( __setting__('pos_y') )) self.s['suppress_progress'] = True if __setting__('suppress_progress') == 'true' else False self.s['suppress_icon'] = True if __setting__('suppress_icon') == 'true' else False self.s['update_on_idle'] = True if __setting__('update_on_idle') == 'true' else False self.s['home_prompts_only'] = True if __setting__('home_prompts_only') == 'true' else False # self.s['export_library'] = True if __setting__('export_library') == 'true' else False # self.s['export_video'] = True if __setting__('export_video') == 'true' else False # self.s['multifile_vid_export'] = True if __setting__('multifile_vid_export') == 'true' else False # self.s['export_music'] = True if __setting__('export_music') == 'true' else False # self.s['create_tarball'] = True if __setting__('create_tarball') == 'true' else False self.s['location_selection'] = __setting__('location_selection') self.s['backup_location'] = __setting__('backup_location') self.s['backup_location_typed'] = __setting__('backup_location_typed') self.s['tarball_count'] = int(float( __setting__('tarball_count') )) self.s['backup_on_update'] = True if __setting__('backup_on_update') == 'true' else False self.s['backup_addons'] = True if __setting__('backup_addons') == 'true' else False self.s['backup_addon_data'] = True if __setting__('backup_addon_data') == 'true' else False self.s['backup_Database'] = True if __setting__('backup_Database') == 'true' else False self.s['backup_keymaps'] = True if __setting__('backup_keymaps') == 'true' else False self.s['backup_library'] = True if __setting__('backup_library') == 'true' else False self.s['backup_playlists'] = True if __setting__('backup_playlists') == 'true' else False self.s['backup_profilesF'] = True if __setting__('backup_profilesF') == 'true' else False self.s['backup_Thumbnails'] = True if __setting__('backup_Thumbnails') == 'true' else False self.s['backup_favourites'] = True if __setting__('backup_favourites') == 'true' else False self.s['backup_keyboard'] = True if __setting__('backup_keyboard') == 'true' else False self.s['backup_remote'] = True if __setting__('backup_remote') == 'true' else False self.s['backup_LCD'] = True if __setting__('backup_LCD') == 'true' else False self.s['backup_profiles'] = True if __setting__('backup_profiles') == 'true' else False self.s['backup_RssFeeds'] = True if __setting__('backup_RssFeeds') == 'true' else False self.s['backup_sources'] = True if __setting__('backup_sources') == 'true' else False self.s['backup_upnpserver'] = True if __setting__('backup_upnpserver') == 'true' else False self.s['backup_peripheral_data'] = True if __setting__('backup_peripheral_data') == 'true' else False self.s['backup_guisettings'] = True if __setting__('backup_guisettings') == 'true' else False self.s['backup_fstab'] = True if __setting__('backup_fstab') == 'true' else False self.s['backup_advancedsettings'] = True if __setting__('backup_advancedsettings') == 'true' else False return "initial run", self.s else: ''' Construct a temporary dictionary for comparison with the existing settings dict ''' tmp_s = {} tmp_s['on_upd_detected'] = int( __setting__('on_upd_detected') ) tmp_s['check_freq'] = int( __setting__('check_freq') ) tmp_s['check_weekday'] = int(float( __setting__('check_weekday') )) tmp_s['check_day'] = int(float( __setting__('check_day') )) tmp_s['check_time'] = int(float( __setting__('check_time') )) tmp_s['check_hour'] = int(float( __setting__('check_hour') )) tmp_s['check_minute'] = int(float( __setting__('check_minute') )) tmp_s['pos_x'] = int(float( __setting__('pos_x') )) tmp_s['pos_y'] = int(float( __setting__('pos_y') )) tmp_s['suppress_progress'] = True if __setting__('suppress_progress') == 'true' else False tmp_s['suppress_icon'] = True if __setting__('suppress_icon') == 'true' else False tmp_s['update_on_idle'] = True if __setting__('update_on_idle') == 'true' else False tmp_s['home_prompts_only'] = True if __setting__('home_prompts_only') == 'true' else False tmp_s['suppress_progress'] = True if __setting__('suppress_progress') == 'true' else False tmp_s['suppress_icon'] = True if __setting__('suppress_icon') == 'true' else False tmp_s['update_on_idle'] = True if __setting__('update_on_idle') == 'true' else False tmp_s['home_prompts_only'] = True if __setting__('home_prompts_only') == 'true' else False # tmp_s['export_library'] = True if __setting__('export_library') == 'true' else False # tmp_s['export_video'] = True if __setting__('export_video') == 'true' else False # tmp_s['multifile_vid_export'] = True if __setting__('multifile_vid_export') == 'true' else False # tmp_s['export_music'] = True if __setting__('export_music') == 'true' else False # tmp_s['create_tarball'] = True if __setting__('create_tarball') == 'true' else False tmp_s['location_selection'] = __setting__('location_selection') tmp_s['backup_location'] = __setting__('backup_location') tmp_s['backup_location_typed'] = __setting__('backup_location_typed') tmp_s['tarball_count'] = int(float( __setting__('tarball_count') )) tmp_s['backup_on_update'] = True if __setting__('backup_on_update') == 'true' else False tmp_s['backup_addons'] = True if __setting__('backup_addons') == 'true' else False tmp_s['backup_addon_data'] = True if __setting__('backup_addon_data') == 'true' else False tmp_s['backup_Database'] = True if __setting__('backup_Database') == 'true' else False tmp_s['backup_keymaps'] = True if __setting__('backup_keymaps') == 'true' else False tmp_s['backup_library'] = True if __setting__('backup_library') == 'true' else False tmp_s['backup_playlists'] = True if __setting__('backup_playlists') == 'true' else False tmp_s['backup_profilesF'] = True if __setting__('backup_profilesF') == 'true' else False tmp_s['backup_Thumbnails'] = True if __setting__('backup_Thumbnails') == 'true' else False tmp_s['backup_favourites'] = True if __setting__('backup_favourites') == 'true' else False tmp_s['backup_keyboard'] = True if __setting__('backup_keyboard') == 'true' else False tmp_s['backup_remote'] = True if __setting__('backup_remote') == 'true' else False tmp_s['backup_LCD'] = True if __setting__('backup_LCD') == 'true' else False tmp_s['backup_profiles'] = True if __setting__('backup_profiles') == 'true' else False tmp_s['backup_RssFeeds'] = True if __setting__('backup_RssFeeds') == 'true' else False tmp_s['backup_sources'] = True if __setting__('backup_sources') == 'true' else False tmp_s['backup_upnpserver'] = True if __setting__('backup_upnpserver') == 'true' else False tmp_s['backup_peripheral_data'] = True if __setting__('backup_peripheral_data') == 'true' else False tmp_s['backup_guisettings'] = True if __setting__('backup_guisettings') == 'true' else False tmp_s['backup_fstab'] = True if __setting__('backup_fstab') == 'true' else False tmp_s['backup_advancedsettings'] = True if __setting__('backup_advancedsettings') == 'true' else False # flags to determine whether the update scheduler needs to be reconstructed or icon repositioned update_scheduler = False reposition_icon = False # check the items in the temp dict and if they are differenct from the current settings, change the current settings, # prompt action if certain settings are changed (like the scheduler settings) for k, v in tmp_s.iteritems(): if v == self.s[k]: continue else: self.s[k] = v if k in self.scheduler_settings: update_scheduler = True elif k in self.icon_settings: reposition_icon = True # if the user has elected to type the backup location, then overwrite the backup_location with the typed version if self.s['location_selection'] == '1': self.s['backup_location'] = self.s['backup_location_typed'] # reconstruct the scheduler if needed if update_scheduler: self.scheduler = sched.SimpleScheduler(self.s) # reposition the icon on the home screen if reposition_icon: self.position_icon() log(self.scheduler.trigger_time, 'trigger_time') return self.s
def update_settings(self): ''' Updates the settings for the service while the service is still running ''' if self.first_run: ''' Construct the settings dicionary ''' self.first_run = False self.scheduler_settings = [ 'check_freq', 'check_weekday', 'check_day', 'check_time', 'check_hour', 'check_minute' ] # self.icon_settings = ['pos_x', 'pos_y'] self.on_upd = [ lang(x) for x in [32057, 32058, 32059, 32060, 32061, 32062] ] self.s = {} log(__setting__('on_upd_detected')) self.s['on_upd_detected'] = int(__setting__('on_upd_detected')) self.s['check_freq'] = int(__setting__('check_freq')) self.s['check_weekday'] = int(float(__setting__('check_weekday'))) self.s['check_day'] = int(float(__setting__('check_day'))) self.s['check_time'] = int(float(__setting__('check_time'))) self.s['check_hour'] = int(float(__setting__('check_hour'))) self.s['check_minute'] = int(float(__setting__('check_minute'))) self.s['check_boot_delay'] = int( float(__setting__('check_boot_delay'))) # self.s['pos_x'] = int(float( __setting__('pos_x') )) # self.s['pos_y'] = int(float( __setting__('pos_y') )) self.s['check_onboot'] = True if __setting__( 'check_onboot') == 'true' else False self.s['suppress_progress'] = True if __setting__( 'suppress_progress') == 'true' else False self.s['suppress_icon'] = True if __setting__( 'suppress_icon') == 'true' else False self.s['ban_update_media'] = True if __setting__( 'ban_update_media') == 'true' else False self.s['update_on_idle'] = True if __setting__( 'update_on_idle') == 'true' else False self.s['home_prompts_only'] = True if __setting__( 'home_prompts_only') == 'true' else False return "initial run", self.s else: ''' Construct a temporary dictionary for comparison with the existing settings dict ''' tmp_s = {} tmp_s['on_upd_detected'] = int(__setting__('on_upd_detected')) tmp_s['check_freq'] = int(__setting__('check_freq')) tmp_s['check_weekday'] = int(float(__setting__('check_weekday'))) tmp_s['check_day'] = int(float(__setting__('check_day'))) tmp_s['check_time'] = int(float(__setting__('check_time'))) tmp_s['check_hour'] = int(float(__setting__('check_hour'))) tmp_s['check_minute'] = int(float(__setting__('check_minute'))) tmp_s['check_boot_delay'] = int( float(__setting__('check_boot_delay'))) # tmp_s['pos_x'] = int(float( __setting__('pos_x') )) # tmp_s['pos_y'] = int(float( __setting__('pos_y') )) tmp_s['check_onboot'] = True if __setting__( 'check_onboot') == 'true' else False tmp_s['suppress_progress'] = True if __setting__( 'suppress_progress') == 'true' else False tmp_s['suppress_icon'] = True if __setting__( 'suppress_icon') == 'true' else False tmp_s['ban_update_media'] = True if __setting__( 'ban_update_media') == 'true' else False tmp_s['update_on_idle'] = True if __setting__( 'update_on_idle') == 'true' else False tmp_s['home_prompts_only'] = True if __setting__( 'home_prompts_only') == 'true' else False # flags to determine whether the update scheduler needs to be reconstructed or icon repositioned update_scheduler = False reposition_icon = False # check the items in the temp dict and if they are differenct from the current settings, change the current settings, # prompt action if certain settings are changed (like the scheduler settings) for k, v in tmp_s.iteritems(): if v == self.s[k]: continue else: self.s[k] = v if k in self.scheduler_settings: update_scheduler = True # elif k in self.icon_settings: # reposition_icon = True # reconstruct the scheduler if needed if update_scheduler: self.scheduler = sched.SimpleScheduler(self.s) # reposition the icon on the home screen if reposition_icon: self.position_icon() log(self.scheduler.trigger_time, 'trigger_time') return self.s
def __init__(self): self.first_run = True # set the hardware prefix self.hw_prefix = get_hardware_prefix() # list of packages that require an external update self.EXTERNAL_UPDATE_REQUIRED_LIST = [ "mediacenter", "lirc-osmc", "eventlircd-osmc", "libcec-osmc", "dbus", "dbus-x11" ] # list of packages that may break compatibility with addons and databases. self.UPDATE_WARNING = False self.UPDATE_WARNING_LIST = [ "-mediacenter-osmc", ] # Items that start with a hyphen should have the hardware prefix attached self.UPDATE_WARNING_LIST = [(str(self.hw_prefix) + x) if x[0] =='-' else x for x in self.UPDATE_WARNING_LIST] log('UPDATE_WARNING_LIST: %s' % self.UPDATE_WARNING_LIST) # the time that the service started self.service_start = datetime.now() # dictionary containing the permissable actions (communicated from the child apt scripts) # and the corresponding methods in the parent self.action_dict = { 'apt_cache update complete' : self.apt_update_complete, 'apt_cache update_manual complete' : self.apt_update_manual_complete, 'apt_cache commit complete' : self.apt_commit_complete, 'apt_cache fetch complete' : self.apt_fetch_complete, 'progress_bar' : self.progress_bar, 'update_settings' : self.update_settings, 'update_now' : self.update_now, 'user_update_now' : self.user_update_now, 'kill_yourself' : self.kill_yourself, 'settings_command' : self.settings_command, 'apt_error' : self.apt_error, 'apt_action_list_error' : self.apt_action_list_error, 'action_list' : self.action_list, 'apt_cache action_list complete' : self.action_list_complete, 'pre_backup_complete' : self.pre_backup_complete, } # queue for communication with the comm and Main self.parent_queue = Queue.Queue() self.randomid = random.randint(0,1000) self.EXTERNAL_UPDATE_REQUIRED = 1 # create socket, listen for comms self.listener = comms.communicator(self.parent_queue, socket_file='/var/tmp/osmc.settings.update.sockfile') self.listener.start() # grab the settings, saves them into a dict called seld.s self.update_settings() # a class to handle scheduling update checks self.scheduler = sched.SimpleScheduler(self.s) log(self.scheduler.trigger_time, 'trigger_time') # this holding pattern holds a function that represents the completion of a process that was put on hold # while the user was watching media or the system was active self.function_holding_pattern = False # monitor for identifying addon settings updates and kodi abort requests self.monitor = Monitah(parent_queue = self.parent_queue) # window onto which to paste the update notification self.window = xbmcgui.Window(10000) # property which determines whether the notification should be pasted to the window self.window.setProperty('OSMC_notification','false') # ControlImage(x, y, width, height, filename[, aspectRatio, colorDiffuse]) self.update_image = xbmcgui.ControlImage(50, 1695, 175, 75, __image_file__) self.try_image_position_again = False self.try_count = 0 self.position_icon() self.window.addControl(self.update_image) self.update_image.setVisibleCondition('[String.Contains(Window(Home).Property(OSMC_notification), true)]') # self.window.setProperty('OSMC_notification', 'true') # USE THIS TO TEST THE UPDATE_ICON # this flag is present when updates have been downloaded but the user wants to choose when to install using # the manual control in the settings self.block_update_file = '/var/tmp/.suppress_osmc_update_checks' # if the file is present, then suppress further update checks and show the notification if os.path.isfile(self.block_update_file): self.skip_update_check = True # if the user has suppressed icon notification of updates and has chosen not to install the updates # its their own damned fault if osmc never get updated if not self.s['suppress_icon']: self.window.setProperty('OSMC_notification', 'true') else: self.skip_update_check = False # check for the external update failed fail_check_file = '/var/tmp/.osmc_failed_update' if os.path.isfile(fail_check_file): with open(fail_check_file, 'r') as f: package = f.readline() ok = DIALOG.ok(lang(32087), lang(32088) % package, '', lang(32089)) try: os.remove(fail_check_file) except: pass self.freespace_supressor = 172200 self.freespace_remedy = 'reboot' # change this to 'apt' to give the user the option to clean the apt files # keep alive method self._daemon()