Skip to content

Commit

Permalink
fix sub-exe call
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrj committed Mar 15, 2024
1 parent 64a1326 commit 3cc4943
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
9 changes: 4 additions & 5 deletions src/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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'

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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}')

Expand Down
19 changes: 17 additions & 2 deletions src/librer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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())

Expand Down

0 comments on commit 3cc4943

Please sign in to comment.