def new_build_check(): log.log("Checking for a new build") check_official = addon.get_bool_setting('check_official') check_interval = addon.get_int_setting('check_interval') autoclose_ms = check_interval * 3540000 # check interval in ms - 1 min try: installed_build = builds.get_installed_build() except: log.log("Unable to get installed build so exiting") sys.exit(1) source = addon.get_setting('source_name') if (isinstance(installed_build, builds.Release) and source == "Official Releases" and not check_official): # Don't do the job of the official auto-update system. log.log("Skipping build check - official release") else: builds.arch = utils.get_arch() if addon.get_bool_setting('set_timeout'): builds.timeout = float(addon.get_setting('timeout')) build_sources = builds.sources() try: build_url = build_sources[source] except KeyError: log.log("{} is not a valid source".format(source)) return log.log("Checking {}".format(build_url.url)) latest = builds.latest_build(source) if latest and latest > installed_build: if utils.do_show_dialog(): log.log("New build {} is available, " "prompting to show build list".format(latest)) if utils.yesno(addon.name, line1=L10n(32027).format( utils.format_build(latest)), line2=L10n(32028).format( utils.format_build(installed_build)), line3=L10n(32029), autoclose=autoclose_ms): with Main() as main: main.start() else: utils.notify( L10n(32030).format(utils.format_build(latest)), 4000)
def new_build_check(): log.log("Checking for a new build") check_official = addon.get_bool_setting('check_official') check_interval = addon.get_int_setting('check_interval') autoclose_ms = check_interval * 3540000 # check interval in ms - 1 min try: installed_build = builds.get_installed_build() except: log.log("Unable to get installed build so exiting") sys.exit(1) source = addon.get_setting('source_name') if (isinstance(installed_build, builds.Release) and source == "Official Releases" and not check_official): # Don't do the job of the official auto-update system. log.log("Skipping build check - official release") else: builds.arch = utils.get_arch() if addon.get_bool_setting('set_timeout'): builds.timeout = float(addon.get_setting('timeout')) build_sources = builds.sources() try: build_url = build_sources[source] except KeyError: log.log("{} is not a valid source".format(source)) return log.log("Checking {}".format(build_url.url)) latest = builds.latest_build(source) if latest and latest > installed_build: if utils.do_show_dialog(): log.log("New build {} is available, " "prompting to show build list".format(latest)) if utils.yesno( addon.name, line1=L10n(32027).format(utils.format_build(latest)), line2=L10n(32028).format(utils.format_build(installed_build)), line3=L10n(32029), autoclose=autoclose_ms): with Main() as main: main.start() else: utils.notify(L10n(32030).format(utils.format_build(latest)), 4000)
def check_archive(self): self.archive = addon.get_bool_setting('archive') if self.archive: archive_root = addon.get_setting('archive_root') self.archive_root = utils.ensure_trailing_slash(archive_root) self.archive_tar_path = None self.archive_dir = os.path.join(self.archive_root, str(self.selected_source)) log.log("Archive builds to " + self.archive_dir) if not xbmcvfs.exists(self.archive_root): log.log("Unable to access archive") utils.ok(L10n(32009), L10n(32010).format(self.archive_root), L10n(32011)) addon.open_settings() sys.exit(1) elif not xbmcvfs.mkdir(self.archive_dir): log.log("Unable to create directory in archive") utils.ok(L10n(32009), L10n(32012).format(self.archive_dir), L10n(32013)) sys.exit(1)
def start(self): if utils.is_running(): raise script_exceptions.AlreadyRunning utils.set_running() log.log("Starting") builds.arch = utils.get_arch() log.log("Set arch to {}".format(builds.arch)) if addon.get_bool_setting('set_timeout'): builds.timeout = float(addon.get_setting('timeout')) self.background = addon.get_bool_setting('background') self.verify_files = addon.get_bool_setting('verify_files') funcs.create_directory(openelec.UPDATE_DIR) utils.check_update_files(builds.get_build_from_notify_file(), force_dialog=True) self.installed_build = self.get_installed_build() self.select_build() utils.remove_update_files() self.check_archive() self.maybe_download() self.maybe_verify() rpi.maybe_disable_overclock() utils.maybe_schedule_extlinux_update() utils.maybe_run_backup() self.confirm()
libreelec, rpi, addon, log, gui, funcs, config, sources) from resources.lib.addon import L10n TEMP_PATH = xbmc.translatePath("special://temp/") if libreelec.OS_RELEASE['NAME'] != "LibreELEC": # Enables testing in Kodi from resources.lib import mock mock.mock_libreelec() libreelec.UPDATE_DIR = TEMP_PATH utils.set_arch() if addon.get_bool_setting('set_timeout'): config.timeout = float(addon.get_setting('timeout')) class Main(object): def __enter__(self): return self def __exit__(self, exc_type, exc_val, exc_tb): already_running = exc_type is script_exceptions.AlreadyRunning if not already_running: utils.set_not_running() return already_running def start(self):
line2=L10n(32028).format( utils.format_build(installed_build)), line3=L10n(32029), autoclose=autoclose_ms): with Main() as main: main.start() else: utils.notify( L10n(32030).format(utils.format_build(latest)), 4000) log.log_version() log.log("Script arguments: {}".format(sys.argv)) if addon.get_bool_setting('set_date_format'): builds.date_fmt = funcs.strftime_fmt(addon.get_setting('date_format')) else: builds.date_fmt = xbmc.getRegion('dateshort') log.log("Set date format to {}".format(builds.date_fmt)) if len(sys.argv) > 1: if sys.argv[1] == 'checkperiodic': if addon.get_bool_setting('check'): selected = builds.get_build_from_notify_file() if not utils.check_update_files(selected): new_build_check() elif sys.argv[1] == 'checkonboot': if addon.get_bool_setting('check'): new_build_check()
line1=L10n(32027).format(utils.format_build(latest)), line2=L10n(32028).format(utils.format_build(installed_build)), line3=L10n(32029), autoclose=autoclose_ms): with Main() as main: main.start() else: utils.notify(L10n(32030).format(utils.format_build(latest)), 4000) log.log_version() log.log("Script arguments: {}".format(sys.argv)) if addon.get_bool_setting('set_date_format'): builds.date_fmt = funcs.strftime_fmt(addon.get_setting('date_format')) else: builds.date_fmt = xbmc.getRegion('dateshort') log.log("Set date format to {}".format(builds.date_fmt)) if len(sys.argv) > 1: if sys.argv[1] == 'checkperiodic': if addon.get_bool_setting('check'): selected = builds.get_build_from_notify_file() if not utils.check_update_files(selected): new_build_check() elif sys.argv[1] == 'checkonboot': if addon.get_bool_setting('check'): new_build_check()