From 3cc4943ecc6771c2c2b5d78fe9ce89dec339d965 Mon Sep 17 00:00:00 2001 From: piotrj Date: Fri, 15 Mar 2024 16:47:45 +0100 Subject: [PATCH] fix sub-exe call --- src/core.py | 9 ++++----- src/librer.py | 19 +++++++++++++++++-- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/core.py b/src/core.py index 28cb4e0..aa47507 100755 --- a/src/core.py +++ b/src/core.py @@ -60,8 +60,6 @@ is_frozen = bool(getattr(sys, 'frozen', False) or "__compiled__" in globals()) -record_exe = ( ('record.exe') if is_frozen else ('python','src\\record.py') ) if windows else ( ('./record') if is_frozen else ('python3','./src/record.py') ) - PARAM_INDICATOR_SIGN = '%' DATA_FORMAT_VERSION='0019' @@ -1418,9 +1416,10 @@ def unload_customdata(self): class LibrerCore: records = set() - def __init__(self,db_dir,log): + def __init__(self,db_dir,record_exe,log): self.records = set() self.db_dir = db_dir + self.record_exe = record_exe self.log=log self.info_line = 'init' @@ -2318,7 +2317,7 @@ def create_new_record(self,temp_dir,update_callback,group=None): new_file_path = sep.join([self.db_dir,f'rep.{int(time())}.dat']) - command = list(record_exe) + command = list(self.record_exe) command.append('create') command.append(new_file_path) command.append(temp_dir) @@ -2482,7 +2481,7 @@ def find_items_in_records(self, record_command_list={} for record_nr,record in enumerate(records_to_process): - curr_command_list = record_command_list[record_nr] = list(record_exe) + curr_command_list = record_command_list[record_nr] = list(self.record_exe) curr_command_list.extend(['search',record.file_path,temp_dir]) self.log.info(f'curr_command_list: {curr_command_list}') diff --git a/src/librer.py b/src/librer.py index 9087c7a..aaa623e 100755 --- a/src/librer.py +++ b/src/librer.py @@ -4845,11 +4845,26 @@ def show_homepage(self): LIBRER_FILE = normpath(__file__) LIBRER_DIR = dirname(LIBRER_FILE) - LIBRER_EXECUTABLE_FILE = normpath(abspath(sys.executable if getattr(sys, 'frozen', False) or "__compiled__" in globals() else sys.argv[0])) + is_frozen = bool(getattr(sys, 'frozen', False) or "__compiled__" in globals()) + + LIBRER_EXECUTABLE_FILE = normpath(abspath(sys.executable if is_frozen else sys.argv[0])) LIBRER_EXECUTABLE_DIR = dirname(LIBRER_EXECUTABLE_FILE) DATA_DIR = sep.join([LIBRER_EXECUTABLE_DIR,'data']) LOG_DIR = sep.join([LIBRER_EXECUTABLE_DIR,'logs']) + if windows: + if is_frozen: + record_exe = [sep.join([LIBRER_EXECUTABLE_DIR,'record.exe']) ] + else: + record_exe = ['python',sep.join([LIBRER_EXECUTABLE_DIR,'record.py']) ] + else: + if is_frozen: + record_exe = [sep.join([LIBRER_EXECUTABLE_DIR,'record']) ] + else: + record_exe = ['python3',sep.join([LIBRER_EXECUTABLE_DIR,'record.py']) ] + + #print(f'{is_frozen=}\n{record_exe=}\n') + ####################################################################### VER_TIMESTAMP = get_ver_timestamp() @@ -4875,7 +4890,7 @@ def show_homepage(self): else: l_info('distro info:\n%s',distro_info) - librer_core = LibrerCore(DATA_DIR,logging) + librer_core = LibrerCore(DATA_DIR,record_exe,logging) Gui(getcwd())