def settings_command(self, action): if action == 'update': self.call_child_script('update_manual') return 'Called child action - update_manual' if action == 'backup': self.update_settings() bckp = OSMC_Backups.osmc_backup(self.s, self.progress_bar) bckp.start_backup() elif action == 'install': # check, _ = self.check_for_legit_updates() # if check == 'bail': # return 'Update not legit, bail' # if not self.EXTERNAL_UPDATE_REQUIRED: # __addon__.setSetting('install_now_visible', 'false') # self.call_child_script('commit') # return 'Called child action - commit' # else: ans = DIALOG.yesno(lang(32072), lang(32075), lang(32076)) if ans: __addon__.setSetting('install_now_visible', 'false') exit_osmc_settings_addon() xbmc.sleep(1000) subprocess.Popen(['sudo', 'systemctl', 'start', 'manual-update']) return "Calling external update"
def settings_command_backup(self): ''' User called to initiate a backup ''' self.update_settings() bckp = OSMC_Backups.osmc_backup(self.s, self.progress_bar) try: bckp.start_backup() except Exception as e: log('Backup Error Type and Args: %s : %s \n\n %s' % (type(e).__name__, e.args, traceback.format_exc())) ok = DIALOG.ok(lang(32096), lang(32097)) return 'Called BACKUP script complete'
def update_now(self): ''' Calls for an update check via the external script. This method checks if media is playing or whether the system has been idle for two minutes before allowing the update. If an update is requested, but media is playing or the system isnt idle, then the update request is put into a loop, with the daemon checking periodically to see if the situation has changed. ''' # do not do anything while there is something in the holding pattern if self.function_holding_pattern: return # check whether the install is an alpha version if self.check_for_unsupported_version() == 'alpha': return check, _ = self.check_update_conditions() if check: if self.s['backup_on_update']: # run backup self.update_settings() bckp = OSMC_Backups.osmc_backup(self.s, self.progress_bar, self.parent_queue) try: bckp.start_backup() except Exception as e: log('Backup Error Type and Args: %s : %s \n\n %s' % (type(e).__name__, e.args, traceback.format_exc())) else: # run the update self.call_child_script('update') else: self.function_holding_pattern = self.holding_pattern_update
def settings_command_restore(self): ''' User called to inititate a restore ''' self.update_settings() bckp = OSMC_Backups.osmc_backup(self.s, self.progress_bar) try: bckp.start_restore() restart_required = bckp.restoring_guisettings if bckp.success != 'Full': ok = DIALOG.ok('Restore','Some items failed to restore.','See log for details.') for x in bckp.success: if x.endswith('userdata/guisettings.xml'): restart_required = False if restart_required: user_input_restart_now = DIALOG.yesno(lang(32110), lang(32098), lang(32099), yeslabel=lang(32100), nolabel=lang(32101)) if user_input_restart_now: subprocess.Popen(['sudo', 'systemctl', 'restart', 'mediacenter']) except Exception as e: log('Backup Error Type and Args: %s : %s \n\n %s' % (type(e).__name__, e.args, traceback.format_exc())) ok = DIALOG.ok(lang(32096), lang(32097)) return 'Called RESTORE script complete'
def settings_command(self, action): if action == 'update': self.call_child_script('update_manual') return 'Called child action - update_manual' if action == 'backup': self.update_settings() bckp = OSMC_Backups.osmc_backup(self.s, self.progress_bar) try: bckp.start_backup() except Exception as e: log('Backup Error Type and Args: %s : %s \n\n %s' % (type(e).__name__, e.args, traceback.format_exc())) ok = DIALOG.ok(lang(32096), lang(32097)) return 'Called BACKUP script complete' if action == 'restore': self.update_settings() bckp = OSMC_Backups.osmc_backup(self.s, self.progress_bar) try: bckp.start_restore() restart_required = bckp.restoring_guisettings if bckp.success != 'Full': ok = DIALOG.ok('Restore','Some items failed to restore.','See log for details.') for x in bckp.success: if x.endswith('userdata/guisettings.xml'): restart_required = False if restart_required: user_input_restart_now = DIALOG.yesno(lang(32110), lang(32098), lang(32099), yeslabel=lang(32100), nolabel=lang(32101)) if user_input_restart_now: subprocess.Popen(['sudo', 'systemctl', 'restart', 'mediacenter']) except Exception as e: log('Backup Error Type and Args: %s : %s \n\n %s' % (type(e).__name__, e.args, traceback.format_exc())) ok = DIALOG.ok(lang(32096), lang(32097)) return 'Called RESTORE script complete' elif action == 'install': # check, _ = self.check_for_legit_updates() # if check == 'bail': # return 'Update not legit, bail' # if not self.EXTERNAL_UPDATE_REQUIRED: # __addon__.setSetting('install_now_visible', 'false') # self.call_child_script('commit') # return 'Called child action - commit' # else: # warn the user if there is a major Kodi update that will be installed # bail if they decide not to proceed if self.UPDATE_WARNING: confirm = self.display_update_warning() if not confirm: return ans = DIALOG.yesno(lang(32072), lang(32075), lang(32076)) if ans: __addon__.setSetting('install_now_visible', 'false') exit_osmc_settings_addon() xbmc.sleep(1000) subprocess.Popen(['sudo', 'systemctl', 'start', 'manual-update']) return "Calling external update"
def settings_command(self, action): if action == 'update': self.call_child_script('update_manual') return 'Called child action - update_manual' if action == 'backup': self.update_settings() bckp = OSMC_Backups.osmc_backup(self.s, self.progress_bar) try: bckp.start_backup() except Exception as e: log('Backup Error Type and Args: %s : %s \n\n %s' % (type(e).__name__, e.args, traceback.format_exc())) ok = DIALOG.ok(lang(32096), lang(32097)) return 'Called BACKUP script complete' if action == 'restore': self.update_settings() bckp = OSMC_Backups.osmc_backup(self.s, self.progress_bar) try: bckp.start_restore() restart_required = bckp.restoring_guisettings if bckp.success != 'Full': ok = DIALOG.ok('Restore', 'Some items failed to restore.', 'See log for details.') for x in bckp.success: if x.endswith('userdata/guisettings.xml'): restart_required = False if restart_required: user_input_restart_now = DIALOG.yesno(lang(32096), lang(32098), lang(32099), yeslabel=lang(32100), nolabel=lang(32101)) if user_input_restart_now: ok = DIALOG.ok( 'OSMC', 'Sorry this has yet to be implemented.') # this should call a script that closes Kodi and overwrites the guisettings.xml with the restored one # subprocess.Popen(['sudo', 'systemctl', 'start', 'NOTHING YET']) except Exception as e: log('Backup Error Type and Args: %s : %s \n\n %s' % (type(e).__name__, e.args, traceback.format_exc())) ok = DIALOG.ok(lang(32096), lang(32097)) return 'Called RESTORE script complete' elif action == 'install': # check, _ = self.check_for_legit_updates() # if check == 'bail': # return 'Update not legit, bail' # if not self.EXTERNAL_UPDATE_REQUIRED: # __addon__.setSetting('install_now_visible', 'false') # self.call_child_script('commit') # return 'Called child action - commit' # else: ans = DIALOG.yesno(lang(32072), lang(32075), lang(32076)) if ans: __addon__.setSetting('install_now_visible', 'false') exit_osmc_settings_addon() xbmc.sleep(1000) subprocess.Popen( ['sudo', 'systemctl', 'start', 'manual-update']) return "Calling external update"
def settings_command(self, action): if action == 'update': self.call_child_script('update_manual') return 'Called child action - update_manual' if action == 'backup': self.update_settings() bckp = OSMC_Backups.osmc_backup(self.s, self.progress_bar) try: bckp.start_backup() except Exception as e: log('Backup Error Type and Args: %s : %s \n\n %s' % (type(e).__name__, e.args, traceback.format_exc())) ok = DIALOG.ok(lang(32096), lang(32097)) return 'Called BACKUP script complete' if action == 'restore': self.update_settings() bckp = OSMC_Backups.osmc_backup(self.s, self.progress_bar) try: bckp.start_restore() except Exception as e: log('Backup Error Type and Args: %s : %s \n\n %s' % (type(e).__name__, e.args, traceback.format_exc())) ok = DIALOG.ok(lang(32096), lang(32097)) return 'Called RESTORE script complete' elif action == 'install': # check, _ = self.check_for_legit_updates() # if check == 'bail': # return 'Update not legit, bail' # if not self.EXTERNAL_UPDATE_REQUIRED: # __addon__.setSetting('install_now_visible', 'false') # self.call_child_script('commit') # return 'Called child action - commit' # else: ans = DIALOG.yesno(lang(32072), lang(32075), lang(32076)) if ans: __addon__.setSetting('install_now_visible', 'false') exit_osmc_settings_addon() xbmc.sleep(1000) subprocess.Popen(['sudo', 'systemctl', 'start', 'manual-update']) return "Calling external update"