Exemplo n.º 1
0
def check_update():
    try:
        update_rule = config.get(["update", "check_update"], "stable")
        if update_rule == "dont-check":
            return

        check_push_update()

        if update_rule != "stable" and update_rule != "test":
            return

        versions = update_from_github.get_github_versions()
        current_version = update_from_github.current_version()
        if update_rule == "test":
            if LooseVersion(current_version) < LooseVersion(versions[0][1]):
                xlog.info("update to test version %s", versions[0][1])
                update_from_github.update_version(versions[0][1])
        elif update_rule == "stable":
            if LooseVersion(current_version) < LooseVersion(versions[1][1]):
                xlog.info("update to stable version %s", versions[1][1])
                update_from_github.update_version(versions[1][1])
    except IOError as e:
        xlog.warn("check update fail:%r", e)
    except Exception as e:
        xlog.exception("check_update fail:%r", e)
Exemplo n.º 2
0
def check_update():
    try:
        update_rule = config.get(["update", "check_update"], "stable")
        if update_rule == "dont-check":
            return

        check_push_update()

        if update_rule != "stable" and update_rule != "test":
            return

        versions = update_from_github.get_github_versions()
        current_version = update_from_github.current_version()
        if update_rule == "test":
            if LooseVersion(current_version) < LooseVersion(versions[0][1]):
                xlog.info("update to test version %s", versions[0][1])
                update_from_github.update_version(versions[0][1])
        elif update_rule == "stable":
            if LooseVersion(current_version) < LooseVersion(versions[1][1]):
                xlog.info("update to stable version %s", versions[1][1])
                update_from_github.update_version(versions[1][1])
    except IOError as e:
        xlog.warn("check update fail:%r", e)
    except Exception as e:
        xlog.exception("check_update fail:%r", e)
Exemplo n.º 3
0
def check_update():
    try:
        if update_from_github.update_info == "dont-check":
            return

        # check_push_update()  # server broken

        update_rule = config.check_update
        if update_rule not in ("stable", "notice-stable", "test",
                               "notice-test"):
            return

        try:
            versions = update_from_github.get_github_versions()
        except Exception as e:
            xlog.warn("check_update get version failed. e:%r", e)
            return

        current_version = update_from_github.current_version()
        test_version, stable_version = versions[0][1], versions[1][1]
        if test_version != config.skip_test_version:
            if update_rule == "notice-test":
                if LooseVersion(current_version) < LooseVersion(test_version):
                    xlog.info("checked new test version %s", test_version)
                    update_from_github.update_info = '{"type":"test", "version":"%s"}' % test_version
            elif update_rule == "test":
                if LooseVersion(current_version) < LooseVersion(test_version):
                    xlog.info("update to test version %s", test_version)
                    update_from_github.update_version(test_version)
        if stable_version != config.skip_stable_version:
            if update_rule == "notice-stable":
                if LooseVersion(current_version) < LooseVersion(
                        stable_version):
                    xlog.info("checked new stable version %s", stable_version)
                    update_from_github.update_info = '{"type":"stable", "version":"%s"}' % stable_version
            elif update_rule == "stable":
                if LooseVersion(current_version) < LooseVersion(
                        stable_version):
                    xlog.info("update to stable version %s", stable_version)
                    update_from_github.update_version(stable_version)
    except IOError as e:
        xlog.exception("check update fail:%r", e)
    except Exception as e:
        xlog.exception("check_update fail:%r", e)
    finally:
        if update_from_github.update_info == "init":
            update_from_github.update_info = ""
Exemplo n.º 4
0
def check_update():
    update_rule = config.get(["update", "check_update"], "dont-check")
    if update_rule == "dont-check":
        return

    check_push_update()

    if update_rule != "stable" and update_rule != "test":
        return

    versions = update_from_github.get_github_versions()
    current_version = update_from_github.current_version()
    if update_rule == "test":
        if LooseVersion(current_version) < LooseVersion(versions[0][1]):
            logging.info("update to test version %s", versions[0][1])
            update_from_github.update_version(versions[0][1])
    elif update_rule == "stable":
        if LooseVersion(current_version) < LooseVersion(versions[1][1]):
            logging.info("update to stable version %s", versions[1][1])
            update_from_github.update_version(versions[1][1])
Exemplo n.º 5
0
def check_update():
    update_rule = config.get(["update", "check_update"], "dont-check")
    if update_rule == "dont-check":
        return

    check_push_update()

    if update_rule != "stable" and update_rule != "test":
        return

    versions = update_from_github.get_github_versions()
    current_version = update_from_github.current_version()
    if update_rule == "test":
        if LooseVersion(current_version) < LooseVersion(versions[0][1]):
            logging.info("update to test version %s", versions[0][1])
            update_from_github.update_version(versions[0][1])
    elif update_rule == "stable":
        if LooseVersion(current_version) < LooseVersion(versions[1][1]):
            logging.info("update to stable version %s", versions[1][1])
            update_from_github.update_version(versions[1][1])
Exemplo n.º 6
0
def check_update():
    try:
        if update_from_github.update_info == "dont-check":
            return

        check_push_update()

        update_rule = config.get(["update", "check_update"], "notice-stable")
        if update_rule not in ("stable", "notice-stable", "test", "notice-test"):
            return

        versions = update_from_github.get_github_versions()
        current_version = update_from_github.current_version()
        test_version, stable_version = versions[0][1], versions[1][1]
        if test_version != config.get(["update", "skip_test_version"]):
            if update_rule == "notice-test":
                if LooseVersion(current_version) < LooseVersion(test_version):
                    xlog.info("checked new test version %s", test_version)
                    update_from_github.update_info = '{"type":"test", "version":"%s"}' % test_version
            elif update_rule == "test":
                if LooseVersion(current_version) < LooseVersion(test_version):
                    xlog.info("update to test version %s", test_version)
                    update_from_github.update_version(test_version)
        if stable_version != config.get(["update", "skip_stable_version"]):
            if update_rule == "notice-stable":
                if LooseVersion(current_version) < LooseVersion(stable_version):
                    xlog.info("checked new stable version %s", stable_version)
                    update_from_github.update_info = '{"type":"stable", "version":"%s"}' % stable_version
            elif update_rule == "stable":
                if LooseVersion(current_version) < LooseVersion(stable_version):
                    xlog.info("update to stable version %s", stable_version)
                    update_from_github.update_version(stable_version)
    except IOError as e:
        xlog.warn("check update fail:%r", e)
    except Exception as e:
        xlog.exception("check_update fail:%r", e)
    finally:
        if update_from_github.update_info == "init":
            update_from_github.update_info = ""
Exemplo n.º 7
0
    def req_config_handler(self):
        req = urlparse.urlparse(self.path).query
        reqs = urlparse.parse_qs(req, keep_blank_values=True)
        data = ''

        current_version = update_from_github.current_version()

        if reqs['cmd'] == ['get_config']:
            config.load()
            check_update = config.get(["update", "check_update"], 1)
            if check_update == 0:
                check_update = "dont-check"
            elif check_update == 1:
                check_update = "long-term-stable"

            data = '{ "check_update": "%s", "popup_webui": %d, "allow_remote_connect": %d, "show_systray": %d, "auto_start": %d, "php_enable": %d, "gae_proxy_enable": %d }' %\
                   (check_update
                    , config.get(["modules", "launcher", "popup_webui"], 1)
                    , config.get(["modules", "launcher", "allow_remote_connect"], 0)
                    , config.get(["modules", "launcher", "show_systray"], 1)
                    , config.get(["modules", "launcher", "auto_start"], 0)
                    , config.get(["modules", "php_proxy", "auto_start"], 0)
                    , config.get(["modules", "gae_proxy", "auto_start"], 0))
        elif reqs['cmd'] == ['set_config']:
            if 'check_update' in reqs:
                check_update = reqs['check_update'][0]
                if check_update not in ["dont-check", "long-term-stable", "stable", "test"]:
                    data = '{"res":"fail, check_update:%s"}' % check_update
                else:
                    config.set(["update", "check_update"], check_update)
                    config.save()

                    data = '{"res":"success"}'

            elif 'popup_webui' in reqs:
                popup_webui = int(reqs['popup_webui'][0])
                if popup_webui != 0 and popup_webui != 1:
                    data = '{"res":"fail, popup_webui:%s"}' % popup_webui
                else:
                    config.set(["modules", "launcher", "popup_webui"], popup_webui)
                    config.save()

                    data = '{"res":"success"}'

            elif 'allow_remote_connect' in reqs:
                allow_remote_connect = int(reqs['allow_remote_connect'][0])
                if allow_remote_connect != 0 and allow_remote_connect != 1:
                    data = '{"res":"fail, allow_remote_connect:%s"}' % allow_remote_connect
                else:
                    config.set(["modules", "launcher", "allow_remote_connect"], allow_remote_connect)
                    config.save()

                    data = '{"res":"success"}'

                    launcher_log.debug("restart web control.")
                    stop()
                    time.sleep(1)
                    start()
                    launcher_log.debug("launcher web control restarted.")

            elif 'show_systray' in reqs:
                show_systray = int(reqs['show_systray'][0])
                if show_systray != 0 and show_systray != 1:
                    data = '{"res":"fail, show_systray:%s"}' % show_systray
                else:
                    config.set(["modules", "launcher", "show_systray"], show_systray)
                    config.save()

                    data = '{"res":"success"}'

            elif 'auto_start' in reqs:
                auto_start = int(reqs['auto_start'][0])
                if auto_start != 0 and auto_start != 1:
                    data = '{"res":"fail, auto_start:%s"}' % auto_start
                else:
                    if auto_start:
                        autorun.enable()
                    else:
                        autorun.disable()

                    config.set(["modules", "launcher", "auto_start"], auto_start)
                    config.save()

                    data = '{"res":"success"}'
            elif 'gae_proxy_enable' in reqs :
                gae_proxy_enable = int(reqs['gae_proxy_enable'][0])
                if gae_proxy_enable != 0 and gae_proxy_enable != 1:
                    data = '{"res":"fail, gae_proxy_enable:%s"}' % gae_proxy_enable
                else:
                    config.set(["modules", "gae_proxy", "auto_start"], gae_proxy_enable)
                    config.save()
                    if gae_proxy_enable:
                        module_init.start("gae_proxy")
                    else:
                        module_init.stop("gae_proxy")
                    self.load_module_menus()
                    data = '{"res":"success"}'
            elif 'php_enable' in reqs :
                php_enable = int(reqs['php_enable'][0])
                if php_enable != 0 and php_enable != 1:
                    data = '{"res":"fail, php_enable:%s"}' % php_enable
                else:
                    config.set(["modules", "php_proxy", "auto_start"], php_enable)
                    config.save()
                    if php_enable:
                        module_init.start("php_proxy")
                    else:
                        module_init.stop("php_proxy")
                    self.load_module_menus()
                    data = '{"res":"success"}'
            else:
                data = '{"res":"fail"}'
        elif reqs['cmd'] == ['get_new_version']:
            versions = update_from_github.get_github_versions()
            data = '{"res":"success", "test_version":"%s", "stable_version":"%s", "current_version":"%s"}' % (versions[0][1], versions[1][1], current_version)
            launcher_log.info("%s", data)
        elif reqs['cmd'] == ['update_version']:
            version = reqs['version'][0]
            try:
                update_from_github.update_version(version)
                data = '{"res":"success"}'
            except Exception as e:
                launcher_log.info("update_test_version fail:%r", e)
                data = '{"res":"fail", "error":"%s"}' % e

        self.send_response('text/html', data)
Exemplo n.º 8
0
    def req_config_handler(self):
        req = urlparse.urlparse(self.path).query
        reqs = urlparse.parse_qs(req, keep_blank_values=True)
        data = ""

        current_version = update_from_github.current_version()

        if reqs["cmd"] == ["get_config"]:
            config.load()
            check_update = config.get(["update", "check_update"], 1)
            if check_update == 0:
                check_update = "dont-check"
            elif check_update == 1:
                check_update = "long-term-stable"

            data = (
                '{ "check_update": "%s", "popup_webui": %d, "show_systray": %d, "auto_start": %d, "php_enable": %d, "goagent_enable": %d }'
                % (
                    check_update,
                    config.get(["modules", "launcher", "popup_webui"], 1),
                    config.get(["modules", "launcher", "show_systray"], 1),
                    config.get(["modules", "launcher", "auto_start"], 0),
                    config.get(["modules", "php_proxy", "auto_start"], 0),
                    config.get(["modules", "goagent", "auto_start"], 0),
                )
            )
        elif reqs["cmd"] == ["set_config"]:
            if "check_update" in reqs:
                check_update = reqs["check_update"][0]
                if check_update not in ["dont-check", "long-term-stable", "stable", "test"]:
                    data = '{"res":"fail, check_update:%s"}' % check_update
                else:
                    config.set(["update", "check_update"], check_update)
                    config.save()

                    data = '{"res":"success"}'

            elif "popup_webui" in reqs:
                popup_webui = int(reqs["popup_webui"][0])
                if popup_webui != 0 and popup_webui != 1:
                    data = '{"res":"fail, popup_webui:%s"}' % popup_webui
                else:
                    config.set(["modules", "launcher", "popup_webui"], popup_webui)
                    config.save()

                    data = '{"res":"success"}'
            elif "show_systray" in reqs:
                show_systray = int(reqs["show_systray"][0])
                if show_systray != 0 and show_systray != 1:
                    data = '{"res":"fail, show_systray:%s"}' % show_systray
                else:
                    config.set(["modules", "launcher", "show_systray"], show_systray)
                    config.save()

                    data = '{"res":"success"}'
            elif "auto_start" in reqs:
                auto_start = int(reqs["auto_start"][0])
                if auto_start != 0 and auto_start != 1:
                    data = '{"res":"fail, auto_start:%s"}' % auto_start
                else:
                    if auto_start:
                        autorun.enable()
                    else:
                        autorun.disable()

                    config.set(["modules", "launcher", "auto_start"], auto_start)
                    config.save()

                    data = '{"res":"success"}'
            elif "goagent_enable" in reqs:
                goagent_enable = int(reqs["goagent_enable"][0])
                if goagent_enable != 0 and goagent_enable != 1:
                    data = '{"res":"fail, goagent_enable:%s"}' % goagent_enable
                else:
                    config.set(["modules", "goagent", "auto_start"], goagent_enable)
                    config.save()
                    if goagent_enable:
                        module_init.start("goagent")
                    else:
                        module_init.stop("goagent")
                    self.load_module_menus()
                    data = '{"res":"success"}'
            elif "php_enable" in reqs:
                php_enable = int(reqs["php_enable"][0])
                if php_enable != 0 and php_enable != 1:
                    data = '{"res":"fail, php_enable:%s"}' % php_enable
                else:
                    config.set(["modules", "php_proxy", "auto_start"], php_enable)
                    config.save()
                    if php_enable:
                        module_init.start("php_proxy")
                    else:
                        module_init.stop("php_proxy")
                    self.load_module_menus()
                    data = '{"res":"success"}'
            else:
                data = '{"res":"fail"}'
        elif reqs["cmd"] == ["get_new_version"]:
            versions = update_from_github.get_github_versions()
            data = '{"res":"success", "test_version":"%s", "stable_version":"%s", "current_version":"%s"}' % (
                versions[0][1],
                versions[1][1],
                current_version,
            )
            logging.info("%s", data)
        elif reqs["cmd"] == ["update_version"]:
            version = reqs["version"][0]
            try:
                update_from_github.update_version(version)
                data = '{"res":"success"}'
            except Exception as e:
                logging.info("update_test_version fail:%r", e)
                data = '{"res":"fail", "error":"%s"}' % e

        self.send_response("text/html", data)
Exemplo n.º 9
0
    def req_config_handler(self):
        req = urlparse.urlparse(self.path).query
        reqs = urlparse.parse_qs(req, keep_blank_values=True)
        data = ''

        current_version = update_from_github.current_version()

        if reqs['cmd'] == ['get_config']:
            config.load()
            check_update = config.get(["update", "check_update"], 1)
            if check_update == 0:
                check_update = "dont-check"
            elif check_update == 1:
                check_update = "stable"

            data = '{ "check_update": "%s", "popup_webui": %d, "allow_remote_connect": %d, "show_systray": %d, "auto_start": %d, "php_enable": %d, "gae_proxy_enable": %d }' %\
                   (check_update
                    , config.get(["modules", "launcher", "popup_webui"], 1)
                    , config.get(["modules", "launcher", "allow_remote_connect"], 0)
                    , config.get(["modules", "launcher", "show_systray"], 1)
                    , config.get(["modules", "launcher", "auto_start"], 0)
                    , config.get(["modules", "php_proxy", "auto_start"], 0)
                    , config.get(["modules", "gae_proxy", "auto_start"], 0))
        elif reqs['cmd'] == ['set_config']:
            if 'check_update' in reqs:
                check_update = reqs['check_update'][0]
                if check_update not in ["dont-check", "stable", "test"]:
                    data = '{"res":"fail, check_update:%s"}' % check_update
                else:
                    config.set(["update", "check_update"], check_update)
                    config.save()

                    data = '{"res":"success"}'

            elif 'popup_webui' in reqs:
                popup_webui = int(reqs['popup_webui'][0])
                if popup_webui != 0 and popup_webui != 1:
                    data = '{"res":"fail, popup_webui:%s"}' % popup_webui
                else:
                    config.set(["modules", "launcher", "popup_webui"], popup_webui)
                    config.save()

                    data = '{"res":"success"}'

            elif 'allow_remote_connect' in reqs:
                allow_remote_connect = int(reqs['allow_remote_connect'][0])
                if allow_remote_connect != 0 and allow_remote_connect != 1:
                    data = '{"res":"fail, allow_remote_connect:%s"}' % allow_remote_connect
                else:
                    config.set(["modules", "launcher", "allow_remote_connect"], allow_remote_connect)
                    config.save()

                    data = '{"res":"success"}'

                    xlog.debug("restart web control.")
                    stop()
                    time.sleep(1)
                    start()
                    xlog.debug("launcher web control restarted.")

            elif 'show_systray' in reqs:
                show_systray = int(reqs['show_systray'][0])
                if show_systray != 0 and show_systray != 1:
                    data = '{"res":"fail, show_systray:%s"}' % show_systray
                else:
                    config.set(["modules", "launcher", "show_systray"], show_systray)
                    config.save()

                    data = '{"res":"success"}'

            elif 'auto_start' in reqs:
                auto_start = int(reqs['auto_start'][0])
                if auto_start != 0 and auto_start != 1:
                    data = '{"res":"fail, auto_start:%s"}' % auto_start
                else:
                    if auto_start:
                        autorun.enable()
                    else:
                        autorun.disable()

                    config.set(["modules", "launcher", "auto_start"], auto_start)
                    config.save()

                    data = '{"res":"success"}'
            elif 'gae_proxy_enable' in reqs :
                gae_proxy_enable = int(reqs['gae_proxy_enable'][0])
                if gae_proxy_enable != 0 and gae_proxy_enable != 1:
                    data = '{"res":"fail, gae_proxy_enable:%s"}' % gae_proxy_enable
                else:
                    config.set(["modules", "gae_proxy", "auto_start"], gae_proxy_enable)
                    config.save()
                    if gae_proxy_enable:
                        module_init.start("gae_proxy")
                    else:
                        module_init.stop("gae_proxy")
                    self.load_module_menus()
                    data = '{"res":"success"}'
            elif 'php_enable' in reqs :
                php_enable = int(reqs['php_enable'][0])
                if php_enable != 0 and php_enable != 1:
                    data = '{"res":"fail, php_enable:%s"}' % php_enable
                else:
                    config.set(["modules", "php_proxy", "auto_start"], php_enable)
                    config.save()
                    if php_enable:
                        module_init.start("php_proxy")
                    else:
                        module_init.stop("php_proxy")
                    self.load_module_menus()
                    data = '{"res":"success"}'
            else:
                data = '{"res":"fail"}'
        elif reqs['cmd'] == ['get_new_version']:
            versions = update_from_github.get_github_versions()
            data = '{"res":"success", "test_version":"%s", "stable_version":"%s", "current_version":"%s"}' % (versions[0][1], versions[1][1], current_version)
            xlog.info("%s", data)
        elif reqs['cmd'] == ['update_version']:
            version = reqs['version'][0]
            try:
                update_from_github.update_version(version)
                data = '{"res":"success"}'
            except Exception as e:
                xlog.info("update_test_version fail:%r", e)
                data = '{"res":"fail", "error":"%s"}' % e

        self.send_response('text/html', data)
Exemplo n.º 10
0
    def req_config_handler(self):
        req = urlparse.urlparse(self.path).query
        reqs = urlparse.parse_qs(req, keep_blank_values=True)
        data = ''

        current_version = update_from_github.current_version()

        if reqs['cmd'] == ['get_config']:
            config.load()
            check_update = config.get(["update", "check_update"], 1)
            if check_update == 0:
                check_update = "dont-check"
            elif check_update == 1:
                check_update = "long-term-stable"

            data = '{ "check_update": "%s", "popup_webui": %d, "auto_start": %d, "php_enable": %d, "goagent_enable": %d }' %\
                   (check_update
                    , config.get(["modules", "launcher", "popup_webui"], 1)
                    , config.get(["modules", "launcher", "auto_start"], 0)
                    , config.get(["modules", "php_proxy", "auto_start"], 0)
                    , config.get(["modules", "goagent", "auto_start"], 0))
        elif reqs['cmd'] == ['set_config']:
            if 'check_update' in reqs:
                check_update = reqs['check_update'][0]
                if check_update not in ["dont-check", "long-term-stable", "stable", "test"]:
                    data = '{"res":"fail, check_update:%s"}' % check_update
                else:
                    config.set(["update", "check_update"], check_update)
                    config.save()

                    data = '{"res":"success"}'

            elif 'popup_webui' in reqs :
                popup_webui = int(reqs['popup_webui'][0])
                if popup_webui != 0 and popup_webui != 1:
                    data = '{"res":"fail, popup_webui:%s"}' % popup_webui
                else:
                    config.set(["modules", "launcher", "popup_webui"], popup_webui)
                    config.save()

                    data = '{"res":"success"}'
            elif 'auto_start' in reqs :
                auto_start = int(reqs['auto_start'][0])
                if auto_start != 0 and auto_start != 1:
                    data = '{"res":"fail, auto_start:%s"}' % auto_start
                else:
                    if auto_start:
                        autorun.enable()
                    else:
                        autorun.disable()

                    config.set(["modules", "launcher", "auto_start"], auto_start)
                    config.save()

                    data = '{"res":"success"}'
            elif 'goagent_enable' in reqs :
                goagent_enable = int(reqs['goagent_enable'][0])
                if goagent_enable != 0 and goagent_enable != 1:
                    data = '{"res":"fail, goagent_enable:%s"}' % goagent_enable
                else:
                    config.set(["modules", "goagent", "auto_start"], goagent_enable)
                    config.save()
                    if goagent_enable:
                        module_init.start("goagent")
                    else:
                        module_init.stop("goagent")
                    self.load_module_menus()
                    data = '{"res":"success"}'
            elif 'php_enable' in reqs :
                php_enable = int(reqs['php_enable'][0])
                if php_enable != 0 and php_enable != 1:
                    data = '{"res":"fail, php_enable:%s"}' % php_enable
                else:
                    config.set(["modules", "php_proxy", "auto_start"], php_enable)
                    config.save()
                    if php_enable:
                        module_init.start("php_proxy")
                    else:
                        module_init.stop("php_proxy")
                    self.load_module_menus()
                    data = '{"res":"success"}'
            else:
                data = '{"res":"fail"}'
        elif reqs['cmd'] == ['get_new_version']:
            versions = update_from_github.get_github_versions()
            data = '{"res":"success", "test_version":"%s", "stable_version":"%s", "current_version":"%s"}' % (versions[0][1], versions[1][1], current_version)
            logging.info("%s", data)
        elif reqs['cmd'] == ['update_version']:
            version = reqs['version'][0]
            try:
                update_from_github.update_version(version)
                data = '{"res":"success"}'
            except Exception as e:
                logging.info("update_test_version fail:%r", e)
                data = '{"res":"fail", "error":"%s"}' % e

        self.send_response('text/html', data)