bug fix in auto git commit

This commit is contained in:
Usman Nasir
2020-03-19 11:39:10 +05:00
parent 0b9646302d
commit ac7436e293
4 changed files with 22 additions and 7 deletions

View File

@@ -246,7 +246,10 @@ class ProcessUtilities(multi.Thread):
def outputExecutioner(command, user=None):
try:
if getpass.getuser() == 'root':
return subprocess.check_output(command, shell=True).decode("utf-8")
if os.path.exists(ProcessUtilities.debugPath):
logging.writeToFile(command)
p = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
return p.communicate()[0].decode("utf-8")
if type(command) == list:
command = " ".join(command)

View File

@@ -1,4 +0,0 @@
import subprocess
command = 'git -C /home/usman/Backup/CyberCP commit -m "Auto commit by CyberPanel Daily cron on"'
print(subprocess.check_output(command, shell=True).decode("utf-8"))

View File

@@ -1240,6 +1240,22 @@ class Upgrade:
except:
pass
query = """CREATE TABLE `websiteFunctions_gitlogs` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`date` datetime(6) NOT NULL,
`type` varchar(5) NOT NULL,
`message` longtext NOT NULL,
`owner_id` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `websiteFunctions_git_owner_id_ce74c7de_fk_websiteFu` (`owner_id`),
CONSTRAINT `websiteFunctions_git_owner_id_ce74c7de_fk_websiteFu` FOREIGN KEY (`owner_id`) REFERENCES `websiteFunctions_websites` (`id`)
)"""
try:
cursor.execute(query)
except:
pass
try:
connection.close()
except:

View File

@@ -3393,12 +3393,12 @@ StrictHostKeyChecking no
command = 'git -C %s push --set-upstream origin %s' % (self.folder, currentBranch)
commandStatus = ProcessUtilities.outputExecutioner(command)
if commandStatus.find('Everything up-to-date') == -1 and commandStatus.find('rejected') == -1:
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}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
else:
data_ret = {'status': 0, 'error_message': 'Push not required.', 'commandStatus': commandStatus}
data_ret = {'status': 0, 'error_message': 'Push failed.', 'commandStatus': commandStatus}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)