Skip to content

Commit a455a3e

Browse files
committed
execute git commands from the repo folder
1 parent 8cac24a commit a455a3e

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

plogical/processUtilities.py

+13-5
Original file line numberDiff line numberDiff line change
@@ -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

websiteFunctions/website.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -4208,14 +4208,14 @@ def webhook(self,domain, data=None):
42084208
GitLogs(owner=self.web, type='INFO',
42094209
message='Running: %s' % (command)).save()
42104210

4211-
result = ProcessUtilities.outputExecutioner(command, self.web.externalApp)
4211+
result = ProcessUtilities.outputExecutioner(command, self.web.externalApp, None, self.folder)
42124212
GitLogs(owner=self.web, type='INFO',
42134213
message='Result: %s' % (result)).save()
42144214
else:
42154215
GitLogs(owner=self.web, type='INFO',
42164216
message='Running: %s' % (gitConf['commands'])).save()
42174217

4218-
result = ProcessUtilities.outputExecutioner(gitConf['commands'], self.web.externalApp)
4218+
result = ProcessUtilities.outputExecutioner(gitConf['commands'], self.web.externalApp, None, self.folder)
42194219
GitLogs(owner=self.web, type='INFO',
42204220
message='Result: %s' % (result)).save()
42214221

0 commit comments

Comments
 (0)