From 4df09116d06aaeb6103cde3a7267361f228df510 Mon Sep 17 00:00:00 2001 From: Usman Nasir Date: Thu, 19 Mar 2020 18:59:27 +0500 Subject: [PATCH] bug fix: status fetch on auto git push --- plogical/processUtilities.py | 7 +++++-- websiteFunctions/website.py | 6 +++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/plogical/processUtilities.py b/plogical/processUtilities.py index a595cb22b..1bfe9b31b 100755 --- a/plogical/processUtilities.py +++ b/plogical/processUtilities.py @@ -243,12 +243,15 @@ class ProcessUtilities(multi.Thread): return 0 @staticmethod - def outputExecutioner(command, user=None): + def outputExecutioner(command, user=None, shell = None): try: if getpass.getuser() == 'root': if os.path.exists(ProcessUtilities.debugPath): logging.writeToFile(command) - p = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + if shell == None or shell == True: + p = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + else: + p = subprocess.Popen(shlex.split(command), stdout=subprocess.PIPE, stderr=subprocess.STDOUT) return p.communicate()[0].decode("utf-8") if type(command) == list: diff --git a/websiteFunctions/website.py b/websiteFunctions/website.py index 41373e45a..44af28b0c 100755 --- a/websiteFunctions/website.py +++ b/websiteFunctions/website.py @@ -3379,11 +3379,11 @@ StrictHostKeyChecking no ## command = 'git -C %s push' % (self.folder) - commandStatus = ProcessUtilities.outputExecutioner(command) + commandStatus = ProcessUtilities.outputExecutioner(command, 'root', False) if commandStatus.find('has no upstream branch') > -1: command = 'git -C %s rev-parse --abbrev-ref HEAD' % (self.folder) - currentBranch = ProcessUtilities.outputExecutioner(command).rstrip('\n') + currentBranch = ProcessUtilities.outputExecutioner(command, 'root', False).rstrip('\n') if currentBranch.find('fatal: ambiguous argument') > -1: data_ret = {'status': 0, 'error_message': 'You need to commit first.', 'commandStatus': 'You need to commit first.'} @@ -3391,7 +3391,7 @@ StrictHostKeyChecking no return HttpResponse(json_data) command = 'git -C %s push --set-upstream origin %s' % (self.folder, currentBranch) - commandStatus = ProcessUtilities.outputExecutioner(command) + commandStatus = ProcessUtilities.outputExecutioner(command, 'root', False) if commandStatus.find('Everything up-to-date') == -1 and commandStatus.find('rejected') == -1 and commandStatus.find('Permission denied') == -1: data_ret = {'status': 1, 'commandStatus': commandStatus}