fix job success calculator

This commit is contained in:
Usman Nasir 2020-05-29 23:39:41 +05:00
parent 7ef5fac736
commit 6769e83aa1
3 changed files with 13 additions and 2 deletions

View File

@ -25,6 +25,9 @@ class FirewallUtilities:
@staticmethod
def addRule(proto,port):
print('Adding port: %s' % (port))
if port == "21":
command = "sudo firewall-cmd --add-service=ftp --permanent"
else:
@ -56,7 +59,6 @@ class FirewallUtilities:
@staticmethod
def deleteRule(proto, port):
print('Adding port: %s' % (port))
if port=="21":
command = "sudo firewall-cmd --remove-service=ftp --permanent"

View File

@ -216,6 +216,7 @@ class backupSchedule:
backupSchedule.remoteBackupLogging(backupLogPath, "")
backupSchedule.remoteBackupLogging(backupLogPath, "")
return 1
else:
backupSchedule.remoteBackupLogging(backupLogPath, 'Remote backup creation failed for %s.' % (virtualHost) )
@ -227,6 +228,7 @@ class backupSchedule:
backupSchedule.remoteBackupLogging(backupLogPath, "")
backupSchedule.remoteBackupLogging(backupLogPath, "")
return 0
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [backupSchedule.createBackup]")
@ -332,8 +334,14 @@ class backupSchedule:
for virtualHost in os.listdir("/home"):
if match(r'^[a-zA-Z0-9-]*[a-zA-Z0-9-]{0,61}[a-zA-Z0-9-](?:\.[a-zA-Z0-9-]{2,})+$', virtualHost, M | I):
backupSchedule.createBackup(virtualHost, ipAddress, backupLogPath, port, user)
if backupSchedule.createBackup(virtualHost, ipAddress, backupLogPath, port, user):
jobSuccessSites = jobSuccessSites + 1
else:
jobFailedSites = jobFailedSites + 1
backupSchedule.backupLog.jobFailedSites = jobFailedSites
backupSchedule.backupLog.jobSuccessSites = jobSuccessSites
backupSchedule.backupLog.save()
backupSchedule.remoteBackupLogging(backupLogPath, "Remote backup job completed.\n")

View File

@ -62,6 +62,7 @@ class backupScheduleLocal:
if retValues[0] == 0:
backupSchedule.remoteBackupLogging(backupLogPath, '[ERROR] Backup failed for %s, error: %s moving on..' % (virtualHost, retValues[1]), backupSchedule.ERROR)
jobFailedSites = jobFailedSites + 1
continue
if os.path.exists(backupScheduleLocal.localBackupPath):