本文整理汇总了Python中module_init.start函数的典型用法代码示例。如果您正苦于以下问题:Python start函数的具体用法?Python start怎么用?Python start使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了start函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: req_init_module_handler
def req_init_module_handler(self):
req = urlparse.urlparse(self.path).query
reqs = urlparse.parse_qs(req, keep_blank_values=True)
data = ""
try:
module = reqs["module"][0]
config.load()
if reqs["cmd"] == ["start"]:
result = module_init.start(module)
data = '{ "module": "%s", "cmd": "start", "result": "%s" }' % (module, result)
elif reqs["cmd"] == ["stop"]:
result = module_init.stop(module)
data = '{ "module": "%s", "cmd": "stop", "result": "%s" }' % (module, result)
elif reqs["cmd"] == ["restart"]:
result_stop = module_init.stop(module)
result_start = module_init.start(module)
data = '{ "module": "%s", "cmd": "restart", "stop_result": "%s", "start_result": "%s" }' % (
module,
result_stop,
result_start,
)
except Exception as e:
logging.exception("init_module except:%s", e)
self.send_response("text/html", data)
示例2: install_module
def install_module(module, new_version):
import module_init
import os, subprocess, sys
current_path = os.path.dirname(os.path.abspath(__file__))
new_module_version_path = os.path.abspath( os.path.join(current_path, os.pardir, os.pardir, module, new_version))
#check path exist
if not os.path.isdir(new_module_version_path):
logging.error("install module %s dir %s not exist", module, new_module_version_path)
return
#call setup.py
setup_script = os.path.join(new_module_version_path, "setup.py")
if not os.path.isfile(setup_script):
logging.warn("update %s fail. setup script %s not exist", module, setup_script)
return
config.set(["modules", module, "current_version"], str(new_version))
config.save()
if module == "launcher":
module_init.stop_all()
import web_control
web_control.stop()
subprocess.Popen([sys.executable, setup_script], shell=False)
os._exit(0)
else:
logging.info("Setup %s version %s ...", module, new_version)
try:
module_init.stop(module)
subprocess.call([sys.executable, setup_script], shell=False)
logging.info("Finished new version setup.")
logging.info("Restarting new version ...")
module_init.start(module)
except Exception as e:
logging.error("install module %s %s fail:%s", module, new_version, e)
示例3: req_init_module_handler
def req_init_module_handler(self):
req = urlparse.urlparse(self.path).query
reqs = urlparse.parse_qs(req, keep_blank_values=True)
data = ''
try:
module = reqs['module'][0]
config.load()
modules_versoin = config.get(['modules', module, 'current_version'], None)
if reqs['cmd'] == ['start']:
result = module_init.start(module)
data = '{ "module": "%s", "cmd": "start", "result": "%s" }' % (module, result)
elif reqs['cmd'] == ['stop']:
result = module_init.stop(module)
data = '{ "module": "%s", "cmd": "stop", "result": "%s" }' % (module, result)
elif reqs['cmd'] == ['restart']:
result_stop = module_init.stop(module)
result_start = module_init.start(module)
data = '{ "module": "%s", "cmd": "restart", "stop_result": "%s", "start_result": "%s" }' % (module, result_stop, result_start)
except Exception as e:
logging.exception("init_module except:%s", e)
self.send_response("text/html", data)
示例4: resetGoagent_
def resetGoagent_(self, _):
module_init.stop("goagent")
module_init.start("goagent")
示例5: req_config_handler
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:
#.........这里部分代码省略.........
示例6: req_config_handler
def req_config_handler(self):
req = urlparse.urlparse(self.path).query
reqs = urlparse.parse_qs(req, keep_blank_values=True)
data = ''
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", "language": "%s", "popup_webui": %d, "allow_remote_connect": %d, \
"show_systray": %d, "auto_start": %d, "show_detail": %d, "php_enable": %d, "gae_proxy_enable": %d, \
"x_tunnel_enable": %d}' %\
(check_update
, config.get(["language"], i18n_translator.lang)
, 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", "gae_proxy", "show_detail"], 0)
, config.get(["modules", "php_proxy", "auto_start"], 0)
, config.get(["modules", "gae_proxy", "auto_start"], 0)
, config.get(["modules", "x_tunnel", "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 'language' in reqs:
language = reqs['language'][0]
if language not in i18n_translator.get_valid_languages():
data = '{"res":"fail, language:%s"}' % language
else:
config.set(["language"], language)
config.save()
i18n_translator.lang = language
self.load_module_menus()
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()
#.........这里部分代码省略.........
示例7: req_config_handler
def req_config_handler(self):
req = urlparse.urlparse(self.path).query
reqs = urlparse.parse_qs(req, keep_blank_values=True)
data = ''
if reqs['cmd'] == ['get_config']:
config.load()
check_update = config.get(["update", "check_update"], "notice-stable")
data = '{ "check_update": "%s", "language": "%s", "popup_webui": %d, "allow_remote_connect": %d, \
"show_systray": %d, "auto_start": %d, "show_detail": %d, "gae_proxy_enable": %d, "x_tunnel_enable": %d, \
"smart_router_enable": %d, "no_mess_system": %d }' %\
(check_update
, config.get(["language"], i18n_translator.lang)
, 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", "gae_proxy", "show_detail"], 0)
, config.get(["modules", "gae_proxy", "auto_start"], 0)
, config.get(["modules", "x_tunnel", "auto_start"], 0)
, config.get(["modules", "smart_router", "auto_start"], 0)
, config.get(["no_mess_system"], 0)
)
if reqs['cmd'] == ['get_version']:
current_version = update_from_github.current_version()
data = '{"current_version":"%s"}' % (current_version)
elif reqs['cmd'] == ['set_config']:
if 'skip_version' in reqs:
skip_version = reqs['skip_version'][0]
skip_version_type = reqs['skip_version_type'][0]
if skip_version_type not in ["stable", "test"]:
data = '{"res":"fail"}'
else:
config.set(["update", "skip_%s_version" % skip_version_type], skip_version)
config.save()
if skip_version in update_from_github.update_info:
update_from_github.update_info = ''
data = '{"res":"success"}'
elif 'check_update' in reqs:
check_update = reqs['check_update'][0]
if check_update not in ["dont-check", "stable", "notice-stable", "test", "notice-test"]:
data = '{"res":"fail, check_update:%s"}' % check_update
else:
if config.get(["update", "check_update"]) != check_update:
update_from_github.init_update_info(check_update)
config.set(["update", "check_update"], check_update)
config.save()
data = '{"res":"success"}'
elif 'language' in reqs:
language = reqs['language'][0]
if language not in i18n_translator.get_valid_languages():
data = '{"res":"fail, language:%s"}' % language
else:
config.set(["language"], language)
config.save()
i18n_translator.lang = language
self.load_module_menus()
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"}'
#.........这里部分代码省略.........
示例8: req_config_handler
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"}' % (
#.........这里部分代码省略.........
示例9: on_restart_gae_proxy
def on_restart_gae_proxy(self, widget=None, data=None):
module_init.stop("gae_proxy")
module_init.start("gae_proxy")
示例10: on_restart_goagent
def on_restart_goagent(self, widget=None, data=None):
module_init.stop("goagent")
module_init.start("goagent")
示例11: req_config_handler
def req_config_handler(self):
req = urlparse.urlparse(self.path).query
reqs = urlparse.parse_qs(req, keep_blank_values=True)
data = ''
if reqs['cmd'] == ['get_config']:
config.load()
if module_init.xargs.get("allow_remote", 0):
allow_remote_connect = 1
else:
allow_remote_connect = config.get(["modules", "launcher", "allow_remote_connect"], 0)
dat = {
"check_update": config.get(["update", "check_update"], "notice-stable"),
"language": config.get(["language"], i18n_translator.lang),
"popup_webui": config.get(["modules", "launcher", "popup_webui"], 1),
"allow_remote_connect": allow_remote_connect,
"allow_remote_switch": config.get(["modules", "launcher", "allow_remote_connect"], 0),
"show_systray": config.get(["modules", "launcher", "show_systray"], 1),
"auto_start": config.get(["modules", "launcher", "auto_start"], 0),
"show_detail": config.get(["modules", "gae_proxy", "show_detail"], 0),
"gae_proxy_enable": config.get(["modules", "gae_proxy", "auto_start"], 0),
"x_tunnel_enable": config.get(["modules", "x_tunnel", "auto_start"], 0),
"smart_router_enable": config.get(["modules", "smart_router", "auto_start"], 0),
"system-proxy": config.get(["modules", "launcher", "proxy"], "smart_router"),
"show-compat-suggest": config.get(["show_compat_suggest"], 1),
"no_mess_system": config.get(["no_mess_system"], 0),
"keep_old_ver_num": config.get(["modules", "launcher", "keep_old_ver_num"], -1), # -1 means not set yet
"postUpdateStat": config.get(["update", "postUpdateStat"], "noChange"),
}
data = json.dumps(dat)
elif reqs['cmd'] == ['set_config']:
if 'skip_version' in reqs:
skip_version = reqs['skip_version'][0]
skip_version_type = reqs['skip_version_type'][0]
if skip_version_type not in ["stable", "test"]:
data = '{"res":"fail"}'
else:
config.set(["update", "skip_%s_version" % skip_version_type], skip_version)
config.save()
if skip_version in update_from_github.update_info:
update_from_github.update_info = ''
data = '{"res":"success"}'
elif 'check_update' in reqs:
check_update = reqs['check_update'][0]
if check_update not in ["dont-check", "stable", "notice-stable", "test", "notice-test"]:
data = '{"res":"fail, check_update:%s"}' % check_update
else:
if config.get(["update", "check_update"]) != check_update:
update_from_github.init_update_info(check_update)
config.set(["update", "check_update"], check_update)
config.save()
data = '{"res":"success"}'
elif 'language' in reqs:
language = reqs['language'][0]
if language not in i18n_translator.get_valid_languages():
data = '{"res":"fail, language:%s"}' % language
else:
config.set(["language"], language)
config.save()
i18n_translator.lang = language
self.load_module_menus()
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_switch' in reqs:
allow_remote_switch = int(reqs['allow_remote_switch'][0])
if allow_remote_switch != 0 and allow_remote_switch != 1:
data = '{"res":"fail, allow_remote_connect:%s"}' % allow_remote_switch
else:
config.set(["modules", "launcher", "allow_remote_connect"], allow_remote_switch)
config.save()
try:
del module_init.xargs["allow_remote"]
except:
pass
if allow_remote_switch:
module_init.call_each_module("set_bind_ip", {
"ip": "0.0.0.0"
})
else:
module_init.call_each_module("set_bind_ip", {
"ip": "127.0.0.1"
})
data = '{"res":"success"}'
#.........这里部分代码省略.........
示例12: restartOssFtp_
def restartOssFtp_(self, _):
module_init.stop('ossftp')
module_init.start('ossftp')
示例13: req_config_handler
def req_config_handler(self):
req = urlparse.urlparse(self.path).query
reqs = urlparse.parse_qs(req, keep_blank_values=True)
data = ''
if reqs['cmd'] == ['get_config']:
config.load()
data = '{ "check_update": "%d", "popup_webui": %d, "auto_start": %d, "php_enable": %d, "goagent_enable": %d }' %\
(config.get(["update", "check_update"], 1)
, 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 = int(reqs['check_update'][0])
if check_update != 0 and check_update != 1:
data = '{"res":"fail, check_update:%s"}' % check_update
else:
config.set(["update", "check_update"], int(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"}'
self.send_response('text/html', data)