diff --git a/tkinter_ui/default.py b/tkinter_ui/default.py index f6c0ed3475..29190225f5 100644 --- a/tkinter_ui/default.py +++ b/tkinter_ui/default.py @@ -5,6 +5,7 @@ import utils.constants as constants from utils.config import config +from utils.tools import resource_path class DefaultUI: @@ -438,12 +439,14 @@ def update_ipv_type(self, event): config.set("Settings", "ipv_type", self.ipv_type_combo.get()) def edit_whitelist_file(self): - if os.path.exists(constants.whitelist_path): - os.system(f'notepad.exe {constants.whitelist_path}') + path = resource_path(constants.whitelist_path) + if os.path.exists(path): + os.system(f'notepad.exe {path}') def edit_blacklist_file(self): - if os.path.exists(constants.blacklist_path): - os.system(f'notepad.exe {constants.blacklist_path}') + path = resource_path(constants.blacklist_path) + if os.path.exists(path): + os.system(f'notepad.exe {path}') def change_entry_state(self, state): for entry in [ diff --git a/tkinter_ui/subscribe.py b/tkinter_ui/subscribe.py index 3c2fda914a..cb885b720e 100644 --- a/tkinter_ui/subscribe.py +++ b/tkinter_ui/subscribe.py @@ -5,6 +5,7 @@ import utils.constants as constants from utils.config import config +from utils.tools import resource_path class SubscribeUI: @@ -51,8 +52,9 @@ def update_open_subscribe(self): config.set("Settings", "open_subscribe", str(self.open_subscribe_var.get())) def edit_subscribe_file(self): - if os.path.exists(constants.subscribe_path): - os.system(f'notepad.exe {constants.subscribe_path}') + path = resource_path(constants.subscribe_path) + if os.path.exists(path): + os.system(f'notepad.exe {path}') def change_entry_state(self, state): for entry in [ diff --git a/tkinter_ui/tkinter_ui.spec b/tkinter_ui/tkinter_ui.spec index 4afc916e5c..ed964dca1b 100644 --- a/tkinter_ui/tkinter_ui.spec +++ b/tkinter_ui/tkinter_ui.spec @@ -8,6 +8,7 @@ a = Analysis( ('../config/config.ini', 'config'), ('../config/demo.txt', 'config'), ('../config/whitelist.txt', 'config'), + ('../config/blacklist.txt', 'config'), ('../config/subscribe.txt', 'config'), ('../config/rtp', 'config/rtp'), ('../updates/hotel/cache.pkl', 'updates/hotel'), diff --git a/utils/config.py b/utils/config.py index 4fb878df66..d517184415 100644 --- a/utils/config.py +++ b/utils/config.py @@ -339,43 +339,18 @@ def copy(self): """ Copy config files to current directory """ - user_source_file = resource_path( - self.config.get("Settings", "source_file", fallback="config/demo.txt") - ) - user_config_path = resource_path("config/user_config.ini") - default_config_path = resource_path("config/config.ini") - user_config_file = ( - user_config_path - if os.path.exists(user_config_path) - else default_config_path - ) dest_folder = os.path.join(os.getcwd(), "config") - files_to_copy = [user_source_file, user_config_file] try: - if os.path.exists(dest_folder): - if not os.path.isdir(dest_folder): - os.remove(dest_folder) + src_dir = resource_path("config") + if os.path.exists(src_dir): + if not os.path.exists(dest_folder): os.makedirs(dest_folder, exist_ok=True) - else: - os.makedirs(dest_folder, exist_ok=True) - for src_file in files_to_copy: - dest_path = os.path.join(dest_folder, os.path.basename(src_file)) - if os.path.abspath(src_file) == os.path.abspath( - dest_path - ) or os.path.exists(dest_path): - continue - shutil.copy(src_file, dest_folder) - src_rtp_dir = resource_path("config/rtp") - dest_rtp_dir = os.path.join(dest_folder, "rtp") - if os.path.exists(src_rtp_dir): - if not os.path.exists(dest_rtp_dir): - os.makedirs(dest_rtp_dir, exist_ok=True) - - for root, _, files in os.walk(src_rtp_dir): + + for root, _, files in os.walk(src_dir): for file in files: src_file_path = os.path.join(root, file) - relative_path = os.path.relpath(src_file_path, src_rtp_dir) - dest_file_path = os.path.join(dest_rtp_dir, relative_path) + relative_path = os.path.relpath(src_file_path, src_dir) + dest_file_path = os.path.join(dest_folder, relative_path) dest_file_dir = os.path.dirname(dest_file_path) if not os.path.exists(dest_file_dir):