diff --git a/.gitignore b/.gitignore index 03e8e20..150fbd8 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,7 @@ .idea # Python -*.pyc +__pycache__ # Data agree-terms @@ -10,3 +10,4 @@ data language share.json config.json +.DS_Store diff --git a/loader/.gitignore b/loader/.gitignore new file mode 100644 index 0000000..d7d173e --- /dev/null +++ b/loader/.gitignore @@ -0,0 +1,2 @@ +logs/ +!./binary/*.pyc \ No newline at end of file diff --git a/loader/binary/api.pyc b/loader/binary/api.pyc new file mode 100644 index 0000000..3d4141d Binary files /dev/null and b/loader/binary/api.pyc differ diff --git a/loader/binary/globals.pyc b/loader/binary/globals.pyc new file mode 100644 index 0000000..ad4255c Binary files /dev/null and b/loader/binary/globals.pyc differ diff --git a/loader/binary/i18n.pyc b/loader/binary/i18n.pyc new file mode 100644 index 0000000..783c090 Binary files /dev/null and b/loader/binary/i18n.pyc differ diff --git a/loader/binary/login.pyc b/loader/binary/login.pyc new file mode 100644 index 0000000..5340890 Binary files /dev/null and b/loader/binary/login.pyc differ diff --git a/loader/binary/main.pyc b/loader/binary/main.pyc new file mode 100644 index 0000000..e941519 Binary files /dev/null and b/loader/binary/main.pyc differ diff --git a/loader/binary/utility.pyc b/loader/binary/utility.pyc new file mode 100644 index 0000000..551a462 Binary files /dev/null and b/loader/binary/utility.pyc differ diff --git a/loader/binary/utils.pyc b/loader/binary/utils.pyc new file mode 100644 index 0000000..aa58944 Binary files /dev/null and b/loader/binary/utils.pyc differ diff --git a/loader/binary/version.txt b/loader/binary/version.txt new file mode 100644 index 0000000..35864a9 --- /dev/null +++ b/loader/binary/version.txt @@ -0,0 +1 @@ +0.8.7 \ No newline at end of file diff --git a/loader/loader.py b/loader/loader.py new file mode 100644 index 0000000..1bd98f6 --- /dev/null +++ b/loader/loader.py @@ -0,0 +1,46 @@ +import importlib +import importlib.machinery +import sys +from pathlib import Path + +_BINARY_DIR = Path(__file__).parent / 'binary' +_MODULES = [ + 'utils', + 'i18n', + 'login', + 'globals', + 'api', + 'main', +] + + +def load_binary(): + sys.path.append(str(_BINARY_DIR)) + + # 先载入并 patch utils + importlib.import_module('utils') + patch_module() + + importlib.import_module('main') + return sys.modules['main'] + + +def patch_module(): + def check_policy(): + from loguru import logger + logger.info('Bypass check_policy') + + sys.modules['utils'].check_policy = check_policy + + +def run_module(module): + module.main() + + +def main(): + module = load_binary() + run_module(module) + + +if __name__ == '__main__': + main()