Skip to content

Commit b8b9c12

Browse files
author
xy
committed
system() call removed
1 parent 6d78943 commit b8b9c12

1 file changed

Lines changed: 22 additions & 21 deletions

File tree

src/librer.py

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
from text import LANGUAGES
6969

7070
from tempfile import mkdtemp
71-
from shlex import quote as shlex_quote
71+
#from shlex import quote as shlex_quote
7272

7373
windows = bool(os_name=='nt')
7474

@@ -6308,22 +6308,10 @@ def update_records_stats(self):
63086308
folder_items_add=folder_items.add
63096309

63106310
def system_wrapper(self,command):
6311-
import os
6312-
env = environ.copy()
6311+
command_string=' '.join(command)
6312+
self.status(f'executing: {command_string}')
63136313

6314-
orig = env.pop("LD_LIBRARY_PATH_ORIG", None)
6315-
if orig is not None:
6316-
l_info(f'{LD_LIBRARY_PATH_ORIG=}')
6317-
env["LD_LIBRARY_PATH"] = orig
6318-
else:
6319-
l_info(f'NO LD_LIBRARY_PATH_ORIG')
6320-
env.pop("LD_LIBRARY_PATH", None)
6321-
6322-
env.pop("LD_PRELOAD", None)
6323-
6324-
self.status(f'executing: {command}')
6325-
6326-
system(command)
6314+
Popen(command,start_new_session=True,env=ENV)
63276315

63286316
@logwrapper
63296317
def open_file(self):
@@ -6341,7 +6329,7 @@ def open_file(self):
63416329
self.status(f'opening: {file_to_open}')
63426330
startfile(file_to_open)
63436331
else:
6344-
command = "xdg-open " + shlex_quote(file_to_open)
6332+
command = ["xdg-open",file_to_open]
63456333
self.system_wrapper(command)
63466334
except Exception as e:
63476335
l_error(e)
@@ -6369,7 +6357,7 @@ def open_location(self):
63696357
self.status(f'opening: {path_to_open}')
63706358
startfile(path_to_open)
63716359
else:
6372-
command = "xdg-open " + shlex_quote(path_to_open)
6360+
command = ["xdg-open",path_to_open]
63736361
self.system_wrapper(command)
63746362
except Exception as e:
63756363
l_error(e)
@@ -6562,7 +6550,7 @@ def show_log(self):
65626550
self.status(f'opening: {log}')
65636551
startfile(log)
65646552
else:
6565-
command="xdg-open "+ shlex_quote(log)
6553+
command=["xdg-open",log]
65666554
self.system_wrapper(command)
65676555
except Exception as e:
65686556
l_error(e)
@@ -6575,7 +6563,7 @@ def show_logs_dir(self):
65756563
self.status(f'opening: {LOG_DIR}')
65766564
startfile(LOG_DIR)
65776565
else:
6578-
command="xdg-open " + shlex_quote(LOG_DIR)
6566+
command=["xdg-open",LOG_DIR]
65796567
self.system_wrapper(command)
65806568
except Exception as e:
65816569
l_error(e)
@@ -6588,7 +6576,7 @@ def show_homepage(self):
65886576
self.status(f'opening: {HOMEPAGE}')
65896577
startfile(HOMEPAGE)
65906578
else:
6591-
command="xdg-open " + shlex_quote(HOMEPAGE)
6579+
command=["xdg-open",HOMEPAGE]
65926580
self.system_wrapper(command)
65936581
except Exception as e:
65946582
l_error(e)
@@ -6651,6 +6639,19 @@ def show_homepage(self):
66516639
l_error(exception_1)
66526640
distro_info = 'Error. No distro.info.txt file.'
66536641

6642+
ENV = environ.copy()
6643+
6644+
LD_LIBRARY_PATH_ORIG = ENV.pop("LD_LIBRARY_PATH_ORIG", None)
6645+
6646+
if LD_LIBRARY_PATH_ORIG is not None:
6647+
l_info(f'{LD_LIBRARY_PATH_ORIG=}')
6648+
ENV["LD_LIBRARY_PATH"] = LD_LIBRARY_PATH_ORIG
6649+
else:
6650+
l_info(f'NO LD_LIBRARY_PATH_ORIG')
6651+
ENV.pop("LD_LIBRARY_PATH", None)
6652+
6653+
ENV.pop("LD_PRELOAD", None)
6654+
66546655
distro_info+= "\nTclVersion " + str(TclVersion) + "\nTkVersion " + str(TkVersion) + "\n" + f'\nrecord file format version: {DATA_FORMAT_VERSION}'
66556656

66566657
l_info('distro info:\n%s',distro_info)

0 commit comments

Comments
 (0)