def confirm(self):
        funcs.create_notify_file(self.selected_source, self.selected_build)

        build_str = utils.format_build(self.selected_build)
        do_notify = False

        if addon.get_bool_setting('confirm_reboot'):
            if utils.yesno(L10n(32022), " ", L10n(32024).format(build_str)):
                xbmc.restart()
            else:
                do_notify = True
        else:
            if progress.reboot_countdown(
                    L10n(32054), L10n(32025).format(build_str),
                    addon.get_int_setting('reboot_count')):
                xbmc.restart()
                sys.exit()
            else:
                do_notify = True

        if do_notify:
            utils.notify(L10n(32026).format(build_str))
    def confirm(self):
        funcs.create_notify_file(self.selected_source, self.selected_build)

        build_str = utils.format_build(self.selected_build)
        do_notify = False

        if addon.get_bool_setting('confirm_reboot'):
            if utils.yesno(L10n(32022), " ", L10n(32024).format(build_str)):
                xbmc.restart()
            else:
                do_notify = True
        else:
            if progress.reboot_countdown(
                    L10n(32054),
                    L10n(32025).format(build_str),
                    addon.get_int_setting('reboot_count')):
                xbmc.restart()
                sys.exit()
            else:
                do_notify = True

        if do_notify:
            utils.notify(L10n(32026).format(build_str))
        build = get_choice(links, build_suffix)
        remote = build.remote_file()
        file_path = os.path.join(openelec.UPDATE_DIR, build.filename)
        print
        print "Downloading {0} ...".format(build.url)
        try:
            with open(file_path, 'w') as out:
                process(remote, out, build.size)
        except KeyboardInterrupt:
            os.remove(file_path)
            print
            print "Download cancelled"
            sys.exit()

        if build.compressed:
            tar_path = os.path.join(openelec.UPDATE_DIR, build.tar_name)
            size = os.path.getsize(file_path)
            print
            print "Decompressing {0} ...".format(file_path)
            with open(file_path, 'r') as fin, open(tar_path, 'w') as fout:
                process(fin, fout, size, decompress)
            os.remove(file_path)

        funcs.create_notify_file(source, build)

        print
        print "The update is ready to be installed. Please reboot."
    else:
        print
        print "No builds available"
Exemple #4
0
        build = get_choice(links, build_suffix, reverse=True)
        remote = build.remote_file()
        file_path = os.path.join(libreelec.UPDATE_DIR, build.filename)
        print
        print "Downloading {0} ...".format(build.url)
        try:
            with open(file_path, 'w') as out:
                process(remote, out, build.size)
        except KeyboardInterrupt:
            os.remove(file_path)
            print
            print "Download cancelled"
            sys.exit()

        if build.compressed:
            tar_path = os.path.join(libreelec.UPDATE_DIR, build.tar_name)
            size = os.path.getsize(file_path)
            print
            print "Decompressing {0} ...".format(file_path)
            with open(file_path, 'r') as fin, open(tar_path, 'w') as fout:
                process(fin, fout, size, decompress)
            os.remove(file_path)

        funcs.create_notify_file(source, build)

        print
        print "The update is ready to be installed. Please reboot."
    else:
        print
        print "No builds available"
Exemple #5
0
def download(args):
    if args.arch:
        config.arch = args.arch

    installed_build = builds.get_installed_build()

    def build_suffix(build):
        if build > installed_build:
            symbol = '+'
        elif build < installed_build:
            symbol = '-'
        else:
            symbol = '='
        return symbol

    build_sources = sources.build_sources()

    if args.source:
        source_name = args.source
        try:
            build_source = build_sources[source_name]
        except KeyError:
            parsed = urlparse(source_name)
            if parsed.scheme in ('http', 'https') and parsed.netloc:
                if args.releases:
                    build_url = builds.BuildsURL(
                        source_name, extractor=builds.ReleaseLinkExtractor)
                else:
                    build_url = builds.BuildsURL(source_name)
            else:
                print(
                    '"{}" is not in the list of available sources '
                    'and is not a valid HTTP URL').format(args.source)
                print 'Valid options are:\n\t{}'.format("\n\t".join(
                    build_sources.keys()))
                sys.exit(1)
    else:
        source_name = get_choice(build_sources.keys())
        build_source = build_sources[source_name]

    print
    print "Arch: {}".format(config.arch)
    print "Installed build: {}".format(installed_build)

    try:
        links = build_source.builds()
    except requests.RequestException as e:
        print str(e)
    except builds.BuildURLError as e:
        print str(e)
    else:
        if links:
            build = get_choice(links, build_suffix, reverse=True)
            remote = build.remote_file()
            file_path = os.path.join(libreelec.UPDATE_DIR, build.filename)
            print
            print "Downloading {0} ...".format(build.url)
            try:
                with open(file_path, 'w') as out:
                    process(remote, out, build.size)
            except KeyboardInterrupt:
                os.remove(file_path)
                print
                print "Download cancelled"
                sys.exit()

            if build.compressed:
                tar_path = os.path.join(libreelec.UPDATE_DIR, build.tar_name)
                size = os.path.getsize(file_path)
                print
                print "Decompressing {0} ...".format(file_path)
                with open(file_path, 'r') as fin, open(tar_path, 'w') as fout:
                    process(fin, fout, size, decompress)
                os.remove(file_path)

            funcs.create_notify_file(source_name, build)

            print
            print "The update is ready to be installed. Please reboot."
        else:
            print
            print "No builds available"