@@ -179,7 +179,7 @@ def setupUDSConnection():
179
179
time .sleep (2 )
180
180
181
181
@staticmethod
182
- def sendCommand (command , user = None ):
182
+ def sendCommand (command , user = None , dir = None ):
183
183
try :
184
184
ret = ProcessUtilities .setupUDSConnection ()
185
185
@@ -201,12 +201,20 @@ def sendCommand(command, user=None):
201
201
if os .path .exists (ProcessUtilities .debugPath ):
202
202
logging .writeToFile (ProcessUtilities .token + command )
203
203
204
- sock .sendall ((ProcessUtilities .token + command ).encode ('utf-8' ))
204
+ if dir == None :
205
+ sock .sendall ((ProcessUtilities .token + command ).encode ('utf-8' ))
206
+ else :
207
+ command = '%s-d %s %s' % (ProcessUtilities .token , dir , command )
208
+ sock .sendall (command .encode ('utf-8' ))
205
209
else :
206
- command = '%s-u %s %s' % (ProcessUtilities .token , user , command )
210
+ if dir == None :
211
+ command = '%s-u %s %s' % (ProcessUtilities .token , user , command )
212
+ else :
213
+ command = '%s-u %s -d %s %s' % (ProcessUtilities .token , user , dir , command )
207
214
command = command .replace ('sudo' , '' )
208
215
if os .path .exists (ProcessUtilities .debugPath ):
209
216
logging .writeToFile (command )
217
+
210
218
sock .sendall (command .encode ('utf-8' ))
211
219
212
220
data = ""
@@ -250,7 +258,7 @@ def executioner(command, user=None, shell=False):
250
258
return 0
251
259
252
260
@staticmethod
253
- def outputExecutioner (command , user = None , shell = None ):
261
+ def outputExecutioner (command , user = None , shell = None , dir = None ):
254
262
try :
255
263
if getpass .getuser () == 'root' :
256
264
if os .path .exists (ProcessUtilities .debugPath ):
@@ -264,7 +272,7 @@ def outputExecutioner(command, user=None, shell = None):
264
272
if type (command ) == list :
265
273
command = " " .join (command )
266
274
267
- return ProcessUtilities .sendCommand (command , user )[:- 1 ]
275
+ return ProcessUtilities .sendCommand (command , user , dir )[:- 1 ]
268
276
except BaseException as msg :
269
277
logging .writeToFile (str (msg ) + "[outputExecutioner:188]" )
270
278
0 commit comments