try: ProxyOverride, reg_type = winreg.QueryValueEx( SETTINGS, 'ProxyOverride') except: ProxyOverride = None #导入默认代理例外地址 if not ProxyOverride: winreg.SetValueEx(SETTINGS, 'ProxyOverride', 0, winreg.REG_SZ, ProxyOverride) Popen((sys.executable, refresh_proxy)) from subprocess import Popen from local import __version__ as gotoxver, clogging as logging logging.replace_logging() logging.addLevelName(15, 'TEST', logging._colors.GREEN) _LOGLv = { 0: logging.WARNING, 1: logging.INFO, 2: logging.TEST, 3: logging.DEBUG } GotoX_app = None def start_GotoX(): global GotoX_app load_config() GotoX_app = Popen((sys.executable, app_start))
def replace_logging(): from local.clogging import replace_logging replace_logging()
import gevent import gevent.monkey gevent.monkey.patch_all(os=False, signal=False, subprocess=False, Event=True) except ImportError: wait_exit( '无法找到 gevent 或者与 Python 版本不匹配,请安装 gevent-1.0.0 ' '以上版本,或将相应 .egg 放到 %r 文件夹!', packages, exc_info=True) except TypeError: gevent.monkey.patch_all(os=False) replace_logging() import logging logging.addLevelName(15, 'TEST', logging.COLORS.GREEN) if gevent.__version__ < '1.0.0': logging.warning('警告:请更新 gevent 至 1.0.0 以上版本!') try: import OpenSSL except ImportError: wait_exit( '无法找到 pyOpenSSL,请安装 pyOpenSSL-16.0.0 以上版本,' '或将相应 .egg 放到 %r 文件夹!', packages, exc_info=True)
def wait_exit(*args, **kwargs): replace_logging() from local.common.util import wait_exit wait_exit(*args, **kwargs)
def replace_logging(): import local.clogging as clogging clogging.replace_logging() clogging.addLevelName(15, 'TEST', clogging.COLORS.GREEN) clogging.preferredEncoding = 'cp936'