Changed execute logic
This commit is contained in:
parent
0539fa41f0
commit
9442453d43
@ -37,7 +37,7 @@ class EventSystem(IPCServer):
|
||||
return None
|
||||
|
||||
|
||||
def push_gui_event(self, eventevent: list) -> None:
|
||||
def push_gui_event(self, event: list) -> None:
|
||||
if len(event) == 3:
|
||||
self._gui_events.append(event)
|
||||
return None
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Python imports
|
||||
import os, gc, threading, time
|
||||
import os, gc, threading, time, shlex
|
||||
|
||||
# Lib imports
|
||||
import gi
|
||||
@ -187,4 +187,4 @@ class Controller(UIMixin, KeyboardSignalsMixin, IPCSignalsMixin, ExceptionHookMi
|
||||
wid, tid = self.fm_controller.get_active_wid_and_tid()
|
||||
tab = self.get_fm_window(wid).get_tab_by_id(tid)
|
||||
dir = tab.get_current_directory()
|
||||
tab.execute(f"{tab.terminal_app}", dir)
|
||||
tab.execute([f"{tab.terminal_app}"], start_dir=shlex.quote(dir))
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Python imports
|
||||
import os, time, threading
|
||||
import os, time, threading, shlex
|
||||
|
||||
# Lib imports
|
||||
import gi
|
||||
@ -145,21 +145,24 @@ class WidgetFileActionMixin:
|
||||
current_dir = state.tab.get_current_directory()
|
||||
command = None
|
||||
for path in paths:
|
||||
command = f"exec '{path}'" if not in_terminal else f"{state.tab.terminal_app} -e '{path}'"
|
||||
state.tab.execute(command, start_dir=state.tab.get_current_directory(), use_os_system=False)
|
||||
command = f"{shlex.quote(path)}" if not in_terminal else f"{state.tab.terminal_app} -e {shlex.quote(path)}"
|
||||
state.tab.execute(shlex.split(command), start_dir=state.tab.get_current_directory())
|
||||
|
||||
def archive_files(self, archiver_dialogue):
|
||||
state = self.get_current_state()
|
||||
paths = self.format_to_uris(state.store, state.wid, state.tid, self.selected_files, True)
|
||||
_paths = self.format_to_uris(state.store, state.wid, state.tid, self.selected_files, True)
|
||||
paths = []
|
||||
for p in _paths:
|
||||
paths.append(shlex.quote(p))
|
||||
|
||||
save_target = archiver_dialogue.get_filename();
|
||||
sItr, eItr = self.arc_command_buffer.get_bounds()
|
||||
pre_command = self.arc_command_buffer.get_text(sItr, eItr, False)
|
||||
pre_command = pre_command.replace("%o", save_target)
|
||||
pre_command = pre_command.replace("%o", shlex.quote(save_target))
|
||||
pre_command = pre_command.replace("%N", ' '.join(paths))
|
||||
command = f"{state.tab.terminal_app} -e '{pre_command}'"
|
||||
command = f"{state.tab.terminal_app} -e {shlex.quote(pre_command)}"
|
||||
|
||||
state.tab.execute(command, start_dir=None, use_os_system=True)
|
||||
state.tab.execute(shlex.split(command), start_dir=shlex.quote(state.tab.get_current_directory()))
|
||||
|
||||
def rename_files(self):
|
||||
rename_label = self.builder.get_object("file_to_rename_label")
|
||||
|
@ -1,7 +1,7 @@
|
||||
# Python imports
|
||||
import copy
|
||||
from os.path import isdir, isfile
|
||||
|
||||
import traceback
|
||||
from os.path import isdir
|
||||
|
||||
# Lib imports
|
||||
import gi
|
||||
@ -206,6 +206,7 @@ class WindowMixin(TabMixin):
|
||||
else:
|
||||
self.open_files()
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
self.display_message(self.error_color, f"{repr(e)}")
|
||||
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
# System import
|
||||
import os, threading, subprocess
|
||||
|
||||
import os, threading, subprocess, shlex
|
||||
|
||||
# Lib imports
|
||||
|
||||
@ -41,19 +40,17 @@ class Launcher:
|
||||
else:
|
||||
command = ["xdg-open", file]
|
||||
|
||||
self.execute(command, use_shell=False)
|
||||
self.execute(command)
|
||||
|
||||
|
||||
def execute(self, command, start_dir=os.getenv("HOME"), use_os_system=None, use_shell=True):
|
||||
def execute(self, command, start_dir=os.getenv("HOME"), use_shell=False):
|
||||
self.logger.debug(command)
|
||||
if use_os_system:
|
||||
os.system(command)
|
||||
else:
|
||||
subprocess.Popen(command, cwd=start_dir, shell=use_shell, start_new_session=True, stdout=None, stderr=None, close_fds=True)
|
||||
subprocess.Popen(command, cwd=start_dir, shell=use_shell, start_new_session=True, stdout=None, stderr=None, close_fds=True)
|
||||
|
||||
def execute_and_return_thread_handler(self, command, start_dir=os.getenv("HOME"), use_shell=True):
|
||||
# TODO: Return stdout and in handlers along with subprocess instead of sinking to null
|
||||
def execute_and_return_thread_handler(self, command, start_dir=os.getenv("HOME"), use_shell=False):
|
||||
DEVNULL = open(os.devnull, 'w')
|
||||
return subprocess.Popen(command, cwd=start_dir, shell=use_shell, start_new_session=True, stdout=DEVNULL, stderr=DEVNULL, close_fds=True)
|
||||
return subprocess.Popen(command, cwd=start_dir, shell=use_shell, start_new_session=False, stdout=DEVNULL, stderr=DEVNULL, close_fds=False)
|
||||
|
||||
@threaded
|
||||
def app_chooser_exec(self, app_info, uris):
|
||||
|
Loading…
Reference in New Issue
Block a user