本文整理汇总了Python中module_init.stop_all函数的典型用法代码示例。如果您正苦于以下问题:Python stop_all函数的具体用法?Python stop_all怎么用?Python stop_all使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了stop_all函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: do_GET
def do_GET(self):
try:
refer = self.headers.getheader("Referer")
netloc = urlparse.urlparse(refer).netloc
if not netloc.startswith("127.0.0.1") and not netloc.startswitch("localhost"):
logging.warn("web control ref:%s refuse", netloc)
return
except:
pass
logging.debug("launcher web_control %s %s %s ", self.address_string(), self.command, self.path)
# check for '..', which will leak file
if re.search(r"(\.{2})", self.path) is not None:
self.wfile.write(b"HTTP/1.1 404\r\n\r\n")
logging.warn("%s %s %s haking", self.address_string(), self.command, self.path)
return
url_path = urlparse.urlparse(self.path).path
if url_path == "/":
return self.req_index_handler()
if len(url_path.split("/")) >= 3 and url_path.split("/")[1] == "modules":
module = url_path.split("/")[2]
# config.load()
modules_version = config.get(["modules", module, "current_version"], None)
file_path = os.path.join(root_path, module, modules_version, url_path.split("/")[3:].join("/"))
else:
file_path = os.path.join(current_path, "web_ui" + url_path)
if os.path.isfile(file_path):
if file_path.endswith(".js"):
mimetype = "application/javascript"
elif file_path.endswith(".css"):
mimetype = "text/css"
elif file_path.endswith(".html"):
mimetype = "text/html"
elif file_path.endswith(".jpg"):
mimetype = "image/jpeg"
elif file_path.endswith(".png"):
mimetype = "image/png"
else:
mimetype = "text/plain"
self.send_file(file_path, mimetype)
elif url_path == "/config":
self.req_config_handler()
elif url_path == "/download":
self.req_download_handler()
elif url_path == "/init_module":
self.req_init_module_handler()
elif url_path == "/quit":
self.send_response("text/html", '{"status":"success"}')
module_init.stop_all()
os._exit(0)
elif url_path == "/restart":
self.send_response("text/html", '{"status":"success"}')
update_from_github.restart_xxnet()
else:
self.wfile.write(b"HTTP/1.1 404\r\nContent-Type: text/plain\r\nConnection: close\r\n\r\n404 Not Found")
logging.info('%s "%s %s HTTP/1.1" 404 -', self.address_string(), self.command, self.path)
示例2: main
def main():
# change path to launcher
global __file__
__file__ = os.path.abspath(__file__)
if os.path.islink(__file__):
__file__ = getattr(os, 'readlink', lambda x: x)(__file__)
os.chdir(os.path.dirname(os.path.abspath(__file__)))
web_control.confirm_xxnet_exit()
setup_win_python.check_setup()
module_init.start_all_auto()
web_control.start()
if config.get(["modules", "launcher", "show_systray"], 1):
sys_tray.serve_forever()
else:
while True:
time.sleep(100)
module_init.stop_all()
sys.exit()
示例3: main
def main():
# change path to launcher
global __file__
__file__ = os.path.abspath(__file__)
if os.path.islink(__file__):
__file__ = getattr(os, "readlink", lambda x: x)(__file__)
os.chdir(os.path.dirname(os.path.abspath(__file__)))
web_control.confirm_xxnet_exit()
setup_win_python.check_setup()
module_init.start_all_auto()
web_control.start()
if has_desktop and config.get(["modules", "launcher", "popup_webui"], 1) == 1:
webbrowser.open("http://127.0.0.1:8085/")
update.start()
if config.get(["modules", "launcher", "show_systray"], 1):
sys_tray.serve_forever()
else:
while True:
time.sleep(100)
module_init.stop_all()
sys.exit()
示例4: main
def main():
# change path to launcher
global __file__
__file__ = os.path.abspath(__file__)
if os.path.islink(__file__):
__file__ = getattr(os, 'readlink', lambda x: x)(__file__)
os.chdir(os.path.dirname(os.path.abspath(__file__)))
launcher_log.info("start XX-Net %s", update_from_github.current_version())
web_control.confirm_xxnet_exit()
setup_win_python.check_setup()
module_init.start_all_auto()
web_control.start()
if has_desktop and config.get(["modules", "launcher", "popup_webui"], 1) == 1:
host_port = config.get(["modules", "launcher", "control_port"], 8085)
webbrowser.open("http://127.0.0.1:%s/" % host_port)
update.start()
if config.get(["modules", "launcher", "show_systray"], 1):
sys_tray.serve_forever()
else:
while True:
time.sleep(100)
module_init.stop_all()
sys.exit()
示例5: do_GET
def do_GET(self):
try:
refer = self.headers.getheader('Referer')
netloc = urlparse.urlparse(refer).netloc
if not netloc.startswith("127.0.0.1") and not netloc.startswitch("localhost"):
logging.warn("web control ref:%s refuse", netloc)
return
except:
pass
logging.debug ('launcher web_control %s "%s %s ', self.address_string(), self.command, self.path)
# check for '..', which will leak file
if re.search(r'(\.{2})', self.path) is not None:
self.wfile.write(b'HTTP/1.1 404\r\n\r\n')
logging.warn('%s %s %s haking', self.address_string(), self.command, self.path )
return
url_path = urlparse.urlparse(self.path).path
if url_path == '/':
return self.req_index_handler()
if len(url_path.split('/')) >= 3 and url_path.split('/')[1] == "modules":
module = url_path.split('/')[2]
#config.load()
modules_versoin = config.get(['modules', module, 'current_version'], None)
file_path = os.path.join(root_path, module, modules_versoin, url_path.split('/')[3:].join('/'))
else:
file_path = os.path.join(current_path, 'web_ui' + url_path)
if os.path.isfile(file_path):
if file_path.endswith('.js'):
mimetype = 'application/javascript'
elif file_path.endswith('.css'):
mimetype = 'text/css'
elif file_path.endswith('.html'):
mimetype = 'text/html'
elif file_path.endswith('.jpg'):
mimetype = 'image/jpeg'
elif file_path.endswith('.png'):
mimetype = 'image/png'
else:
mimetype = 'text/plain'
self.send_file(file_path, mimetype)
elif url_path == '/config':
self.req_config_handler()
elif url_path == '/init_module':
self.req_init_module_handler()
elif url_path == '/quit':
self.send_response('text/html', '{"status":"success"}')
module_init.stop_all()
os._exit(0)
elif url_path == '/restart':
self.send_response('text/html', '{"status":"success"}')
update_from_github.restart_xxnet()
else:
self.wfile.write(b'HTTP/1.1 404\r\nContent-Type: text/plain\r\nConnection: close\r\n\r\n404 Not Found')
logging.info('%s "%s %s HTTP/1.1" 404 -', self.address_string(), self.command, self.path)
示例6: on_quit
def on_quit(self, widget, data=None):
proxy_setting = config.get(["modules", "launcher", "proxy"], "disable")
if proxy_setting != "disable":
win32_proxy_manager.disable_proxy()
module_init.stop_all()
nid = win32_adapter.NotifyData(self.systray._hwnd, 0)
win32_adapter.Shell_NotifyIcon(2, ctypes.byref(nid))
os._exit(0)
示例7: restart_xxnet
def restart_xxnet(version):
import module_init
module_init.stop_all()
import web_control
web_control.stop()
start_script = os.path.join(top_path, "code", version, "launcher", "start.py")
subprocess.Popen([sys.executable, start_script])
time.sleep(20)
示例8: restart_xxnet
def restart_xxnet():
import module_init
module_init.stop_all()
import web_control
web_control.stop()
current_path = os.path.dirname(os.path.abspath(__file__))
start_sript = os.path.abspath( os.path.join(current_path, os.pardir, "start.py"))
subprocess.Popen([sys.executable, start_sript], shell=False)
示例9: restart_xxnet
def restart_xxnet():
import module_init
module_init.stop_all()
import web_control
web_control.stop()
current_path = os.path.dirname(os.path.abspath(__file__))
start_script = os.path.join(current_path, "start.py")
subprocess.Popen([sys.executable, start_script])
time.sleep(10)
os._exit(0)
示例10: main
def main():
# change path to launcher
global __file__
__file__ = os.path.abspath(__file__)
if os.path.islink(__file__):
__file__ = getattr(os, 'readlink', lambda x: x)(__file__)
os.chdir(os.path.dirname(os.path.abspath(__file__)))
current_version = update_from_github.current_version()
xlog.info("start XX-Net %s", current_version)
web_control.confirm_xxnet_exit()
setup_win_python.check_setup()
last_run_version = config.get(["modules", "launcher", "last_run_version"], "0.0.0")
if last_run_version != current_version:
import post_update
post_update.run(last_run_version)
config.set(["modules", "launcher", "last_run_version"], current_version)
config.save()
allow_remote = 0
if len(sys.argv) > 1:
for s in sys.argv[1:]:
xlog.info("command args:%s", s)
if s == "-allow_remote":
allow_remote = 1
module_init.xargs["allow_remote"] = 1
module_init.start_all_auto()
web_control.start(allow_remote)
if has_desktop and config.get(["modules", "launcher", "popup_webui"], 1) == 1:
host_port = config.get(["modules", "launcher", "control_port"], 8085)
import webbrowser
webbrowser.open("http://127.0.0.1:%s/" % host_port)
update.start()
update_from_github.delete_to_save_disk()
if config.get(["modules", "launcher", "show_systray"], 1):
sys_tray.serve_forever()
else:
while True:
time.sleep(100)
module_init.stop_all()
sys.exit()
示例11: 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)
示例12: windowWillClose_
def windowWillClose_(self, notification):
listNetworkServicesCommand = 'networksetup -listallnetworkservices'
executeResult = subprocess.check_output(listNetworkServicesCommand, shell=True)
services = executeResult.split('\n')
services = filter(lambda service : service and service.find('*') == -1 and self.getProxyState(service) != 'disable', services) # Remove disabled services and empty lines
if len(services) > 0:
disableAutoProxyCommand = ';'.join(map(self.getDisableAutoProxyCommand, services))
disableGlobalProxyCommand = ';'.join(map(self.getDisableGlobalProxyCommand, services))
rootCommand = """osascript -e 'do shell script "%s;%s" with administrator privileges' """ % (disableAutoProxyCommand, disableGlobalProxyCommand)
executeCommand = rootCommand.encode('utf-8')
xlog.info("try disable proxy:%s", executeCommand)
os.system(executeCommand)
self.updateConfig('disable')
module_init.stop_all()
os._exit(0)
NSApp.terminate_(self)
示例13: windowWillClose_
def windowWillClose_(self, notification):
executeResult = subprocess.check_output(['networksetup', '-listallnetworkservices'])
services = executeResult.split('\n')
services = filter(lambda service : service and service.find('*') == -1 and getProxyState(service) != 'disable', services) # Remove disabled services and empty lines
if len(services) > 0:
try:
map(helperDisableAutoProxy, services)
map(helperDisableGlobalProxy, services)
except:
disableAutoProxyCommand = ';'.join(map(getDisableAutoProxyCommand, services))
disableGlobalProxyCommand = ';'.join(map(getDisableGlobalProxyCommand, services))
executeCommand = 'do shell script "%s;%s" with administrator privileges' % (disableAutoProxyCommand, disableGlobalProxyCommand)
xlog.info("try disable proxy:%s", executeCommand)
subprocess.call(['osascript', '-e', executeCommand])
module_init.stop_all()
os._exit(0)
AppKit.NSApp.terminate_(self)
示例14: restart_xxnet
def restart_xxnet(version=None):
import module_init
module_init.stop_all()
import web_control
web_control.stop()
# New process will hold the listen port
# We should close all listen port before create new process
xlog.info("Close web control port.")
if version is None:
current_version_file = os.path.join(top_path, "code", "version.txt")
with open(current_version_file, "r") as fd:
version = fd.read()
xlog.info("restart to xx-net version:%s", version)
start_script = os.path.join(top_path, "code", version, "launcher", "start.py")
subprocess.Popen([sys.executable, start_script])
time.sleep(20)
xlog.info("Exit old process...")
os._exit(0)
示例15: on_restart_goagent
def on_restart_goagent(self, widget=None, data=None):
module_init.stop_all()
module_init.start_all_auto()