@@ -179,7 +179,7 @@ def setupUDSConnection():
179179 time .sleep (2 )
180180
181181 @staticmethod
182- def sendCommand (command , user = None ):
182+ def sendCommand (command , user = None , dir = None ):
183183 try :
184184 ret = ProcessUtilities .setupUDSConnection ()
185185
@@ -201,12 +201,20 @@ def sendCommand(command, user=None):
201201 if os .path .exists (ProcessUtilities .debugPath ):
202202 logging .writeToFile (ProcessUtilities .token + command )
203203
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' ))
205209 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 )
207214 command = command .replace ('sudo' , '' )
208215 if os .path .exists (ProcessUtilities .debugPath ):
209216 logging .writeToFile (command )
217+
210218 sock .sendall (command .encode ('utf-8' ))
211219
212220 data = ""
@@ -250,7 +258,7 @@ def executioner(command, user=None, shell=False):
250258 return 0
251259
252260 @staticmethod
253- def outputExecutioner (command , user = None , shell = None ):
261+ def outputExecutioner (command , user = None , shell = None , dir = None ):
254262 try :
255263 if getpass .getuser () == 'root' :
256264 if os .path .exists (ProcessUtilities .debugPath ):
@@ -264,7 +272,7 @@ def outputExecutioner(command, user=None, shell = None):
264272 if type (command ) == list :
265273 command = " " .join (command )
266274
267- return ProcessUtilities .sendCommand (command , user )[:- 1 ]
275+ return ProcessUtilities .sendCommand (command , user , dir )[:- 1 ]
268276 except BaseException as msg :
269277 logging .writeToFile (str (msg ) + "[outputExecutioner:188]" )
270278
0 commit comments