From 3dda5a94cfd8110924e5028acfa2531c1ee9261a Mon Sep 17 00:00:00 2001 From: lededev Date: Mon, 18 Apr 2022 01:27:46 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BD=B1=E7=89=87=E5=88=AE=E5=89=8A=E6=97=B6Ct?= =?UTF-8?q?rl+C=E7=AB=8B=E5=88=BB=E9=80=80=E5=87=BA=EF=BC=8C=E8=80=8C?= =?UTF-8?q?=E4=B8=8D=E6=98=AF=E5=8A=A0=E5=85=A5=E5=A4=B1=E8=B4=A5=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E5=B9=B6=E8=B7=B3=E5=88=B0=E4=B8=8B=E4=B8=80=E9=83=A8?= =?UTF-8?q?=E5=BD=B1=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ADC_function.py | 4 ++-- Movie_Data_Capture.py | 6 +++--- config.py | 10 +++++----- core.py | 9 +++++---- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/ADC_function.py b/ADC_function.py index 8165019..71d4fd9 100644 --- a/ADC_function.py +++ b/ADC_function.py @@ -467,7 +467,7 @@ def download_file_with_filename(url: str, filename: str, path: str) -> None: os.makedirs(path) except: print(f"[-]Fatal error! Can not make folder '{path}'") - sys.exit(0) + os._exit(0) proxies = configProxy.proxies() headers = { 'User-Agent': G_USER_AGENT} @@ -484,7 +484,7 @@ def download_file_with_filename(url: str, filename: str, path: str) -> None: os.makedirs(path) except: print(f"[-]Fatal error! Can not make folder '{path}'") - sys.exit(0) + os._exit(0) headers = { 'User-Agent': G_USER_AGENT} r = requests.get(url, timeout=configProxy.timeout, headers=headers) diff --git a/Movie_Data_Capture.py b/Movie_Data_Capture.py index 672671d..4173c29 100644 --- a/Movie_Data_Capture.py +++ b/Movie_Data_Capture.py @@ -304,7 +304,7 @@ def close_logfile(logdir: str): def signal_handler(*args): print('[!]Ctrl+C detected, Exit.') - sys.exit(9) + os._exit(9) def sigdebug_handler(*args): @@ -426,7 +426,7 @@ def create_failed_folder(failed_folder: str): os.makedirs(failed_folder) except: print(f"[-]Fatal error! Can not make folder '{failed_folder}'") - sys.exit(0) + os._exit(0) def rm_empty_folder(path): @@ -517,7 +517,7 @@ def main(args: tuple) -> Path: folder_path = "" if main_mode not in (1, 2, 3): print(f"[-]Main mode must be 1 or 2 or 3! You can run '{os.path.basename(sys.argv[0])} --help' for more help.") - sys.exit(4) + os._exit(4) signal.signal(signal.SIGINT, signal_handler) if sys.platform == 'win32': diff --git a/config.py b/config.py index 4b105b8..edfabe5 100644 --- a/config.py +++ b/config.py @@ -69,17 +69,17 @@ class Config: elif (Path(__file__).resolve().parent / 'config.ini').is_file(): res_path = Path(__file__).resolve().parent / 'config.ini' if res_path is None: - sys.exit(2) + os._exit(2) ins = input("Or, Do you want me create a config file for you? (Yes/No)[Y]:") if re.search('n', ins, re.I): - sys.exit(2) + os._exit(2) # 用户目录才确定具有写权限,因此选择 ~/mdc.ini 作为配置文件生成路径,而不是有可能并没有写权限的 # 当前目录。目前版本也不再鼓励使用当前路径放置配置文件了,只是作为多配置文件的切换技巧保留。 write_path = path_search_order[2] # Path.home() / "mdc.ini" write_path.write_text(res_path.read_text(encoding='utf-8'), encoding='utf-8') print("Config file '{}' created.".format(write_path.resolve())) input("Press Enter key exit...") - sys.exit(0) + os._exit(0) # self.conf = self._default_config() # try: # self.conf = configparser.ConfigParser() @@ -90,7 +90,7 @@ class Config: # except Exception as e: # print("[-]Config file not found! Use the default settings") # print("[-]",e) - # sys.exit(3) + # os._exit(3) # #self.conf = self._default_config() def set_override(self, option_cmd: str): @@ -110,7 +110,7 @@ class Config: """ def err_exit(str): print(str) - sys.exit(2) + os._exit(2) sections = self.conf.sections() sec_name = None diff --git a/core.py b/core.py index b664b04..7b493cf 100644 --- a/core.py +++ b/core.py @@ -1,5 +1,6 @@ import json import os.path +import os import pathlib import re import shutil @@ -104,7 +105,7 @@ def create_folder(json_data): # 创建文件夹 os.makedirs(path) except: print(f"[-]Fatal error! Can not make folder '{path}'") - sys.exit(0) + os._exit(0) return os.path.normpath(path) @@ -124,7 +125,7 @@ def download_file_with_filename(url, filename, path, filepath): os.makedirs(path) except: print(f"[-]Fatal error! Can not make folder '{path}'") - sys.exit(0) + os._exit(0) proxies = configProxy.proxies() headers = { 'User-Agent': G_USER_AGENT} @@ -141,7 +142,7 @@ def download_file_with_filename(url, filename, path, filepath): os.makedirs(path) except: print(f"[-]Fatal error! Can not make folder '{path}'") - sys.exit(0) + os._exit(0) headers = { 'User-Agent': G_USER_AGENT} r = requests.get(url, timeout=configProxy.timeout, headers=headers) @@ -292,7 +293,7 @@ def print_files(path, leak_word, c_word, naming_rule, part, cn_sub, json_data, f os.makedirs(path) except: print(f"[-]Fatal error! can not make folder '{path}'") - sys.exit(0) + os._exit(0) old_nfo = None try: