From 7f51ba1514e802e1366f7bb3c491915c34947f6a Mon Sep 17 00:00:00 2001 From: yoshiko2 Date: Tue, 4 May 2021 20:08:55 +0800 Subject: [PATCH] Remove custom config file path --- AV_Data_Capture.py | 9 +++++---- config.py | 26 +++++++++++++++----------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/AV_Data_Capture.py b/AV_Data_Capture.py index d52fe11..2d2367c 100755 --- a/AV_Data_Capture.py +++ b/AV_Data_Capture.py @@ -34,14 +34,14 @@ def argparse_function(ver: str) -> [str, str, bool]: parser = argparse.ArgumentParser() parser.add_argument("file", default='', nargs='?', help="Single Movie file path.") parser.add_argument("-p","--path",default='',nargs='?',help="Analysis folder path.") - parser.add_argument("-c", "--config", default='config.ini', nargs='?', help="The config file Path.") + # parser.add_argument("-c", "--config", default='config.ini', nargs='?', help="The config file Path.") parser.add_argument("-n", "--number", default='', nargs='?', help="Custom file number") parser.add_argument("-a", "--auto-exit", dest='autoexit', action="store_true", help="Auto exit after program complete") parser.add_argument("-v", "--version", action="version", version=ver) args = parser.parse_args() - return args.file, args.path, args.config, args.number, args.autoexit + return args.file, args.path, args.number, args.autoexit def movie_lists(root, escape_folder): @@ -137,14 +137,15 @@ if __name__ == '__main__': version = '4.6.2' # Parse command line args - single_file_path, folder_path, config_file, custom_number, auto_exit = argparse_function(version) + single_file_path, folder_path, custom_number, auto_exit = argparse_function(version) print('[*]================== AV Data Capture ===================') print('[*]' + version.center(54)) print('[*]======================================================') # Read config.ini - conf = config.Config(path=config_file) + conf = config.Config("config.ini") + if conf.update_check(): check_update(version) diff --git a/config.py b/config.py index 7f53984..7dbf901 100644 --- a/config.py +++ b/config.py @@ -1,8 +1,8 @@ import os +import sys import configparser import codecs - class Config: def __init__(self, path: str = "config.ini"): if os.path.exists(path): @@ -12,16 +12,20 @@ class Config: except: self.conf.read(path, encoding="utf-8") else: - try: - self.conf = configparser.ConfigParser() - try: # From single crawler debug use only - self.conf.read('../' + path, encoding="utf-8-sig") - except: - self.conf.read('../' + path, encoding="utf-8") - except Exception as e: - print("[-]Config file not found! Use the default settings") - print("[-]",e) - self.conf = self._default_config() + print("[-]Config file not found!") + sys.exit(3) + # self.conf = self._default_config() + # try: + # self.conf = configparser.ConfigParser() + # try: # From single crawler debug use only + # self.conf.read('../' + path, encoding="utf-8-sig") + # except: + # self.conf.read('../' + path, encoding="utf-8") + # except Exception as e: + # print("[-]Config file not found! Use the default settings") + # print("[-]",e) + # sys.exit(3) + # #self.conf = self._default_config() def main_mode(self) -> str: try: