Skip to content
Permalink
Browse files
execute git commands from the repo folder
  • Loading branch information
usmannasir committed Jun 22, 2020
1 parent 8cac24a commit a455a3eab403b461729041d2d837ec456295dfd2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
@@ -179,7 +179,7 @@ def setupUDSConnection():
time.sleep(2)

@staticmethod
def sendCommand(command, user=None):
def sendCommand(command, user=None, dir=None):
try:
ret = ProcessUtilities.setupUDSConnection()

@@ -201,12 +201,20 @@ def sendCommand(command, user=None):
if os.path.exists(ProcessUtilities.debugPath):
logging.writeToFile(ProcessUtilities.token + command)

sock.sendall((ProcessUtilities.token + command).encode('utf-8'))
if dir == None:
sock.sendall((ProcessUtilities.token + command).encode('utf-8'))
else:
command = '%s-d %s %s' % (ProcessUtilities.token, dir, command)
sock.sendall(command.encode('utf-8'))
else:
command = '%s-u %s %s' % (ProcessUtilities.token, user, command)
if dir == None:
command = '%s-u %s %s' % (ProcessUtilities.token, user, command)
else:
command = '%s-u %s -d %s %s' % (ProcessUtilities.token, user, dir, command)
command = command.replace('sudo', '')
if os.path.exists(ProcessUtilities.debugPath):
logging.writeToFile(command)

sock.sendall(command.encode('utf-8'))

data = ""
@@ -250,7 +258,7 @@ def executioner(command, user=None, shell=False):
return 0

@staticmethod
def outputExecutioner(command, user=None, shell = None):
def outputExecutioner(command, user=None, shell = None, dir = None):
try:
if getpass.getuser() == 'root':
if os.path.exists(ProcessUtilities.debugPath):
@@ -264,7 +272,7 @@ def outputExecutioner(command, user=None, shell = None):
if type(command) == list:
command = " ".join(command)

return ProcessUtilities.sendCommand(command, user)[:-1]
return ProcessUtilities.sendCommand(command, user, dir)[:-1]
except BaseException as msg:
logging.writeToFile(str(msg) + "[outputExecutioner:188]")

@@ -4208,14 +4208,14 @@ def webhook(self,domain, data=None):
GitLogs(owner=self.web, type='INFO',
message='Running: %s' % (command)).save()

result = ProcessUtilities.outputExecutioner(command, self.web.externalApp)
result = ProcessUtilities.outputExecutioner(command, self.web.externalApp, None, self.folder)
GitLogs(owner=self.web, type='INFO',
message='Result: %s' % (result)).save()
else:
GitLogs(owner=self.web, type='INFO',
message='Running: %s' % (gitConf['commands'])).save()

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

0 comments on commit a455a3e

Please sign in to comment.