@@ -13,16 +13,18 @@ class CustomWorker(QObject):
13
13
finished = pyqtSignal ()
14
14
data_ready = pyqtSignal (object )
15
15
16
- def __init__ (self ,cmd ,return_type ,hide_empty ):
16
+ def __init__ (self ,cmd ,use_shell , encoding , return_type ,hide_empty ):
17
17
super ().__init__ ()
18
18
self .cmd = cmd
19
+ self .use_shell = use_shell
20
+ self .encoding = encoding
19
21
self .return_type = return_type
20
22
self .hide_empty = hide_empty
21
23
22
24
def run (self ):
23
25
exec_data = None
24
26
if self .cmd :
25
- proc = subprocess .Popen (self .cmd ,stdout = subprocess .PIPE ,stderr = subprocess .DEVNULL ,creationflags = subprocess .CREATE_NO_WINDOW ,shell = True )
27
+ proc = subprocess .Popen (self .cmd ,stdout = subprocess .PIPE ,stderr = subprocess .DEVNULL ,creationflags = subprocess .CREATE_NO_WINDOW ,shell = self . use_shell , encoding = self . encoding )
26
28
output = proc .stdout .read ()
27
29
if self .return_type == "json" :
28
30
try :
@@ -53,6 +55,8 @@ def __init__(
53
55
self ._exec_data = None
54
56
self ._exec_cmd = exec_options ['run_cmd' ].split (" " )if exec_options .get ('run_cmd' ,False )else None
55
57
self ._exec_return_type = exec_options ['return_format' ]
58
+ self ._exec_shell = exec_options ['use_shell' ]
59
+ self ._exec_encoding = exec_options ['encoding' ]
56
60
self ._hide_empty = exec_options ['hide_empty' ]
57
61
self ._show_alt_label = False
58
62
self ._label_content = label
@@ -160,7 +164,7 @@ def _update_label(self):
160
164
161
165
def _exec_callback (self ):
162
166
if self ._exec_cmd :
163
- worker = CustomWorker (self ._exec_cmd ,self ._exec_return_type ,self ._hide_empty )
167
+ worker = CustomWorker (self ._exec_cmd ,self ._exec_shell , self . _exec_encoding , self . _exec_return_type ,self ._hide_empty )
164
168
worker_thread = threading .Thread (target = worker .run )
165
169
worker .data_ready .connect (self ._handle_exec_data )
166
170
worker .finished .connect (worker .deleteLater )
@@ -186,4 +190,4 @@ def _cb_execute_subprocess(self, cmd: str, *cmd_args: list[str]):
186
190
if cmd in function_map :
187
191
function_map [cmd ]()
188
192
else :
189
- subprocess .Popen ([cmd ,* cmd_args ]if cmd_args else [cmd ],shell = True )
193
+ subprocess .Popen ([cmd ,* cmd_args ]if cmd_args else [cmd ],shell = self . _exec_shell , encoding = self . _exec_encoding )