This commit is contained in:
Usman Nasir
2019-12-10 15:09:10 +05:00
parent d0dc397463
commit 5e7aeeb597
231 changed files with 1698 additions and 1697 deletions

View File

@@ -13,7 +13,7 @@ class CyberCPLogFileWriter:
"%m.%d.%Y_%H-%M-%S") + "] "+ message + "\n")
file.close()
except IOError,msg:
except IOError as msg:
return "Can not write to error file."
@staticmethod
@@ -35,7 +35,7 @@ class CyberCPLogFileWriter:
return lastFewLines
except subprocess.CalledProcessError,msg:
except subprocess.CalledProcessError as msg:
return "File was empty"
@staticmethod
@@ -47,8 +47,8 @@ class CyberCPLogFileWriter:
statusFile = open(tempStatusPath, 'a')
statusFile.writelines(mesg + '\n')
statusFile.close()
print(mesg + '\n')
except BaseException, msg:
print((mesg + '\n'))
except BaseException as msg:
CyberCPLogFileWriter.writeToFile(str(msg) + ' [statusWriter]')
#print str(msg)

View File

@@ -30,7 +30,7 @@ class ACLManager:
f = open(ipFile)
ipData = f.read()
serverIPAddress = ipData.split('\n', 1)[0]
except BaseException, msg:
except BaseException as msg:
serverIPAddress = "192.168.100.1"
finalResponse['serverIPAddress'] = serverIPAddress
@@ -534,7 +534,7 @@ class ACLManager:
return 0, 'Something bad happened'
else:
return 1, 'None'
except CalledProcessError, msg:
except CalledProcessError as msg:
logging.writeToFile(str(msg) + ' [ACLManager.executeCall]')
return 0, str(msg)

View File

@@ -46,7 +46,7 @@ class ApplicationInstaller(multi.Thread):
elif self.installApp == 'magento':
self.installMagento()
except BaseException, msg:
except BaseException as msg:
logging.writeToFile(str(msg) + ' [ApplicationInstaller.run]')
def installWPCLI(self):
@@ -60,7 +60,7 @@ class ApplicationInstaller(multi.Thread):
command = 'sudo mv wp-cli.phar /usr/bin/wp'
ProcessUtilities.executioner(command)
except BaseException, msg:
except BaseException as msg:
logging.writeToFile(str(msg) + ' [ApplicationInstaller.installWPCLI]')
def dataLossCheck(self, finalPath, tempStatusPath):
@@ -106,7 +106,7 @@ class ApplicationInstaller(multi.Thread):
command = 'sudo yum install git -y'
ProcessUtilities.executioner(command)
except BaseException, msg:
except BaseException as msg:
logging.writeToFile(str(msg) + ' [ApplicationInstaller.installGit]')
def dbCreation(self, tempStatusPath, website):
@@ -141,7 +141,7 @@ class ApplicationInstaller(multi.Thread):
return dbName, dbUser, dbPassword
except BaseException, msg:
except BaseException as msg:
logging.writeToFile(str(msg) + '[ApplicationInstallerdbCreation]')
def installWordPress(self):
@@ -298,7 +298,7 @@ class ApplicationInstaller(multi.Thread):
return 0
except BaseException, msg:
except BaseException as msg:
# remove the downloaded files
FNULL = open(os.devnull, 'w')
@@ -469,7 +469,7 @@ class ApplicationInstaller(multi.Thread):
return 0
except BaseException, msg:
except BaseException as msg:
# remove the downloaded files
homeDir = "/home/" + domainName + "/public_html"
@@ -568,7 +568,7 @@ class ApplicationInstaller(multi.Thread):
try:
command = 'git clone --depth 1 --no-single-branch git@' + defaultProvider + '.com:' + username + '/' + reponame + '.git -b ' + branch + ' ' + finalPath
ProcessUtilities.executioner(command, externalApp)
except subprocess.CalledProcessError, msg:
except subprocess.CalledProcessError as msg:
statusFile = open(tempStatusPath, 'w')
statusFile.writelines(
'Failed to clone repository, make sure you deployed your key to repository. [404]')
@@ -596,7 +596,7 @@ class ApplicationInstaller(multi.Thread):
return 0
except BaseException, msg:
except BaseException as msg:
os.remove('/home/cyberpanel/' + domainName + '.git')
statusFile = open(tempStatusPath, 'w')
statusFile.writelines(str(msg) + " [404]")
@@ -636,7 +636,7 @@ class ApplicationInstaller(multi.Thread):
return 0
except BaseException, msg:
except BaseException as msg:
logging.writeToFile(str(msg) + " [ApplicationInstaller.gitPull]")
return 0
@@ -679,7 +679,7 @@ class ApplicationInstaller(multi.Thread):
return 0
except BaseException, msg:
except BaseException as msg:
logging.writeToFile(str(msg) + " [ApplicationInstaller.gitPull]")
return 0
@@ -829,7 +829,7 @@ class ApplicationInstaller(multi.Thread):
statusFile.close()
return 0
except BaseException, msg:
except BaseException as msg:
# remove the downloaded files
homeDir = "/home/" + domainName + "/public_html"
@@ -873,11 +873,11 @@ class ApplicationInstaller(multi.Thread):
try:
command = 'sudo git --git-dir=' + finalPath + '/.git checkout ' + githubBranch
ProcessUtilities.executioner(command, externalApp)
except subprocess.CalledProcessError, msg:
except subprocess.CalledProcessError as msg:
logging.writeToFile('Failed to change branch: ' + str(msg))
return 0
return 0
except BaseException, msg:
except BaseException as msg:
logging.writeToFile('Failed to change branch: ' + str(msg))
return 0
@@ -1038,7 +1038,7 @@ class ApplicationInstaller(multi.Thread):
return 0
except BaseException, msg:
except BaseException as msg:
# remove the downloaded files
homeDir = "/home/" + domainName + "/public_html"

View File

@@ -30,7 +30,7 @@ class BackupManager:
try:
currentACL = ACLManager.loadedACL(userID)
return render(request, 'backup/index.html', currentACL)
except BaseException, msg:
except BaseException as msg:
return HttpResponse(str(msg))
def backupSite(self, request = None, userID = None, data = None):
@@ -42,7 +42,7 @@ class BackupManager:
websitesName = ACLManager.findAllSites(currentACL, userID)
return render(request, 'backup/backup.html', {'websiteList': websitesName})
except BaseException, msg:
except BaseException as msg:
return HttpResponse(str(msg))
def restoreSite(self, request = None, userID = None, data = None):
@@ -70,7 +70,7 @@ class BackupManager:
return render(request, 'backup/restore.html', {'backups': all_files})
except BaseException, msg:
except BaseException as msg:
return HttpResponse(str(msg))
def getCurrentBackups(self, userID = None, data = None):
@@ -112,7 +112,7 @@ class BackupManager:
json_data = json_data + ']'
final_json = json.dumps({'status': 1, 'fetchStatus': 1, 'error_message': "None", "data": json_data})
return HttpResponse(final_json)
except BaseException, msg:
except BaseException as msg:
final_dic = {'status': 0, 'fetchStatus': 0, 'error_message': str(msg)}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
@@ -151,7 +151,7 @@ class BackupManager:
final_json = json.dumps({'status': 1, 'metaStatus': 1, 'error_message': "None", 'tempStorage': tempStoragePath})
return HttpResponse(final_json)
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg))
final_dic = {'status': 0, 'metaStatus': 0, 'error_message': str(msg)}
final_json = json.dumps(final_dic)
@@ -213,7 +213,7 @@ class BackupManager:
for items in backupObs:
items.delete()
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [backupStatus]")
final_json = json.dumps(
@@ -229,7 +229,7 @@ class BackupManager:
final_json = json.dumps({'backupStatus': 0, 'error_message': "None", "status": 0, "abort": 0})
return HttpResponse(final_json)
except BaseException, msg:
except BaseException as msg:
final_dic = {'backupStatus': 0, 'error_message': str(msg)}
final_json = json.dumps(final_dic)
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [backupStatus]")
@@ -250,13 +250,13 @@ class BackupManager:
try:
backupOb = Backups.objects.get(fileName=fileName)
backupOb.delete()
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [cancelBackupCreation]")
final_json = json.dumps({'abortStatus': 1, 'error_message': "None", "status": 0})
return HttpResponse(final_json)
except BaseException, msg:
except BaseException as msg:
final_dic = {'abortStatus': 0, 'error_message': str(msg)}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
@@ -276,7 +276,7 @@ class BackupManager:
final_json = json.dumps({'status': 1, 'deleteStatus': 1, 'error_message': "None"})
return HttpResponse(final_json)
except BaseException, msg:
except BaseException as msg:
final_dic = {'status': 0, 'deleteStatus': 0, 'error_message': str(msg)}
final_json = json.dumps(final_dic)
@@ -300,7 +300,7 @@ class BackupManager:
final_dic = {'restoreStatus': 1, 'error_message': "None"}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
except BaseException, msg:
except BaseException as msg:
final_dic = {'restoreStatus': 0, 'error_message': str(msg)}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
@@ -347,7 +347,7 @@ class BackupManager:
'running': 'Running..'})
return HttpResponse(final_json)
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg))
status = "Just Started"
final_json = json.dumps(
@@ -360,7 +360,7 @@ class BackupManager:
'abort': 1})
return HttpResponse(final_json)
except BaseException, msg:
except BaseException as msg:
final_dic = {'restoreStatus': 0, 'error_message': str(msg)}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
@@ -374,7 +374,7 @@ class BackupManager:
return render(request, 'backup/backupDestinations.html', {})
except BaseException, msg:
except BaseException as msg:
return HttpResponse(str(msg))
def submitDestinationCreation(self, userID = None, data = None):
@@ -436,7 +436,7 @@ class BackupManager:
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
except BaseException, msg:
except BaseException as msg:
final_dic = {'destStatus': 0, 'error_message': str(msg)}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
@@ -471,7 +471,7 @@ class BackupManager:
final_json = json.dumps({'fetchStatus': 1, 'error_message': "None", "data": json_data})
return HttpResponse(final_json)
except BaseException, msg:
except BaseException as msg:
final_dic = {'fetchStatus': 0, 'error_message': str(msg)}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
@@ -499,7 +499,7 @@ class BackupManager:
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
except BaseException, msg:
except BaseException as msg:
final_dic = {'connStatus': 1, 'error_message': str(msg)}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
@@ -552,7 +552,7 @@ class BackupManager:
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
except BaseException, msg:
except BaseException as msg:
final_dic = {'delStatus': 1, 'error_message': str(msg)}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
@@ -579,7 +579,7 @@ class BackupManager:
return render(request, 'backup/backupSchedule.html', {'destinations': destinations})
except BaseException, msg:
except BaseException as msg:
return HttpResponse(str(msg))
def getCurrentBackupSchedules(self, userID = None, data = None):
@@ -610,7 +610,7 @@ class BackupManager:
final_json = json.dumps({'fetchStatus': 1, 'error_message': "None", "data": json_data})
return HttpResponse(final_json)
except BaseException, msg:
except BaseException as msg:
final_dic = {'fetchStatus': 0, 'error_message': str(msg)}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
@@ -811,7 +811,7 @@ class BackupManager:
final_json = json.dumps({'scheduleStatus': 1, 'error_message': "None"})
return HttpResponse(final_json)
except BaseException, msg:
except BaseException as msg:
final_json = json.dumps({'scheduleStatus': 0, 'error_message': str(msg)})
return HttpResponse(final_json)
@@ -939,7 +939,7 @@ class BackupManager:
final_json = json.dumps({'delStatus': 1, 'error_message': "None"})
return HttpResponse(final_json)
except BaseException, msg:
except BaseException as msg:
final_json = json.dumps({'delStatus': 0, 'error_message': str(msg)})
return HttpResponse(final_json)
@@ -952,7 +952,7 @@ class BackupManager:
return render(request, 'backup/remoteBackups.html')
except BaseException, msg:
except BaseException as msg:
return HttpResponse(str(msg))
def submitRemoteBackups(self, userID = None, data = None):
@@ -995,7 +995,7 @@ class BackupManager:
return HttpResponse(data_ret)
except BaseException, msg:
except BaseException as msg:
data_ret = {'status': 0,
'error_message': "Not able to fetch version of remote server. Error Message: " + str(
msg),
@@ -1067,14 +1067,14 @@ class BackupManager:
data['error_message'], "dir": "Null"}
data_ret = json.dumps(data_ret)
return HttpResponse(data_ret)
except BaseException, msg:
except BaseException as msg:
data_ret = {'status': 0,
'error_message': "Not able to fetch accounts from remote server. Error Message: " + str(
msg), "dir": "Null"}
data_ret = json.dumps(data_ret)
return HttpResponse(data_ret)
except BaseException, msg:
except BaseException as msg:
final_json = json.dumps({'status': 0, 'error_message': str(msg)})
return HttpResponse(final_json)
@@ -1132,13 +1132,13 @@ class BackupManager:
data['error_message']})
return HttpResponse(final_json)
except BaseException, msg:
except BaseException as msg:
final_json = json.dumps({'remoteTransferStatus': 0,
'error_message': "Can not initiate remote transfer. Error message: " +
str(msg)})
return HttpResponse(final_json)
except BaseException, msg:
except BaseException as msg:
final_json = json.dumps({'remoteTransferStatus': 0, 'error_message': str(msg)})
return HttpResponse(final_json)
@@ -1182,7 +1182,7 @@ class BackupManager:
'backupsSent': 0}
json_data = json.dumps(data)
return HttpResponse(json_data)
except BaseException, msg:
except BaseException as msg:
data = {'remoteTransferStatus': 0, 'error_message': str(msg), 'backupsSent': 0}
json_data = json.dumps(data)
return HttpResponse(json_data)
@@ -1213,7 +1213,7 @@ class BackupManager:
json_data = json.dumps(data)
return HttpResponse(json_data)
except BaseException, msg:
except BaseException as msg:
data = {'remoteRestoreStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data)
return HttpResponse(json_data)
@@ -1260,7 +1260,7 @@ class BackupManager:
"complete": 0}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
except BaseException, msg:
except BaseException as msg:
data = {'remoteTransferStatus': 0, 'error_message': str(msg), "status": "None", "complete": 0}
json_data = json.dumps(data)
return HttpResponse(json_data)
@@ -1306,7 +1306,7 @@ class BackupManager:
json_data = json.dumps(data)
return HttpResponse(json_data)
except BaseException, msg:
except BaseException as msg:
data = {'cancelStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data)
return HttpResponse(json_data)

View File

@@ -25,9 +25,9 @@ class backupSchedule:
try:
file = open(fileName,'a')
file.writelines("[" + time.strftime("%m.%d.%Y_%H-%M-%S") + "] "+ message + "\n")
print ("[" + time.strftime("%m.%d.%Y_%H-%M-%S") + "] "+ message + "\n")
print(("[" + time.strftime("%m.%d.%Y_%H-%M-%S") + "] "+ message + "\n"))
file.close()
except IOError,msg:
except IOError as msg:
return "Can not write to error file."
@staticmethod
@@ -66,7 +66,7 @@ class backupSchedule:
if os.path.exists(status):
status = open(status, 'r').read()
print status
print(status)
time.sleep(2)
if status.find("Completed") > -1:
@@ -114,7 +114,7 @@ class backupSchedule:
except:
pass
return 0, tempStoragePath
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [119:startBackup]")
return 0, str(msg)
@@ -160,7 +160,7 @@ class backupSchedule:
backupSchedule.remoteBackupLogging(backupLogPath, "")
backupSchedule.remoteBackupLogging(backupLogPath, "")
except BaseException,msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [backupSchedule.createBackup]")
@staticmethod
@@ -184,7 +184,7 @@ class backupSchedule:
os.remove(backupPath)
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [189:startBackup]")
@staticmethod
@@ -241,7 +241,7 @@ class backupSchedule:
except BaseException,msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [prepare]")
def main():

View File

@@ -50,7 +50,7 @@ class backupScheduleLocal:
writeToFile.close()
except BaseException,msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [214:startBackup]")
def main():

View File

@@ -123,12 +123,12 @@ class backupUtilities:
for it in dbusers:
dbuser = it
break
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
'While creating backup for %s, we failed to backup database %s. Error message: %s' % (
backupDomain, items.dbName, str(msg)))
continue
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
'While creating backup for %s, we failed to backup database %s. Error message: %s' % (
backupDomain, items.dbName, str(msg)))
@@ -163,7 +163,7 @@ class backupUtilities:
metaFileXML.append(aliasesXML)
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.statusWriter(status, '%s. [167:prepMeta]' % (str(msg)))
## Finish Alias
@@ -191,7 +191,7 @@ class backupUtilities:
metaFileXML.append(dnsRecordsXML)
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.statusWriter(status, '%s. [158:prepMeta]' % (str(msg)))
## Email accounts XML
@@ -212,7 +212,7 @@ class backupUtilities:
emailRecordsXML.append(emailRecordXML)
metaFileXML.append(emailRecordsXML)
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.statusWriter(status, '%s. [179:prepMeta]' % (str(msg)))
## Email meta generated!
@@ -235,7 +235,7 @@ class backupUtilities:
metaFile = open(metaPath, 'w')
metaFile.write(xmlpretty)
metaFile.close()
os.chmod(metaPath, 0777)
os.chmod(metaPath, 0o777)
## meta generated
@@ -249,7 +249,7 @@ class backupUtilities:
return 1,'None', metaPath
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.statusWriter(status, "%s [207][5009]" % (str(msg)))
return 0,str(msg)
@@ -304,9 +304,9 @@ class backupUtilities:
make_archive(os.path.join(tempStoragePath,"public_html"), 'gztar', os.path.join("/home",domainName,"public_html"))
logging.CyberCPLogFileWriter.statusWriter(status, "Backing up databases..")
print '1,None'
print('1,None')
except BaseException,msg:
except BaseException as msg:
try:
os.remove(os.path.join(backupPath,backupName+".tar.gz"))
except:
@@ -319,7 +319,7 @@ class backupUtilities:
status = os.path.join(backupPath, 'status')
logging.CyberCPLogFileWriter.statusWriter(status, "Aborted, "+ str(msg) + ".[365] [5009]")
print ("Aborted, "+ str(msg) + ".[365] [5009]")
print(("Aborted, "+ str(msg) + ".[365] [5009]"))
@staticmethod
def BackupRoot(tempStoragePath, backupName, backupPath, metaPath=None):
@@ -340,7 +340,7 @@ class backupUtilities:
os.path.join(tempStoragePath, domainName + ".fullchain.pem"))
copy(os.path.join(sslStoragePath, "privkey.pem"),
os.path.join(tempStoragePath, domainName + ".privkey.pem"))
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile('%s. [283:startBackup]' % (str(msg)))
## Child Domains SSL.
@@ -372,7 +372,7 @@ class backupUtilities:
sslStoragePath)
except:
pass
except BaseException, msg:
except BaseException as msg:
pass
## backup emails
@@ -390,7 +390,7 @@ class backupUtilities:
try:
make_archive(os.path.join(tempStoragePath, domainName), 'gztar', os.path.join("/home", "vmail", domainName))
except BaseException, msg:
except BaseException as msg:
pass
@@ -431,7 +431,7 @@ class backupUtilities:
pid = open(backupPath + 'pid', "w")
pid.write(str(p.pid))
pid.close()
except BaseException,msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [initiateBackup]")
@staticmethod
@@ -518,7 +518,7 @@ class backupUtilities:
return 1,'None'
except BaseException, msg:
except BaseException as msg:
return 0, str(msg)
@staticmethod
@@ -587,7 +587,7 @@ class backupUtilities:
copy(completPath + "/" + masterDomain + ".fullchain.pem", sslHome + "/fullchain.pem")
sslUtilities.installSSLForDomain(masterDomain)
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile('%s. [555:startRestore]' % (str(msg)))
else:
@@ -653,7 +653,7 @@ class backupUtilities:
else:
logging.CyberCPLogFileWriter.statusWriter(status, "Error Message: " + retValues[1] + ". Not able to create child domains, aborting. [635][5009]")
return 0
except BaseException, msg:
except BaseException as msg:
status = open(os.path.join(completPath,'status'), "w")
status.write("Error Message: " + str(msg) +". Not able to create child domains, aborting. [638][5009]")
status.close()
@@ -686,7 +686,7 @@ class backupUtilities:
if result[0] == 0:
raise BaseException(result[1])
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.statusWriter(status, "Error Message: " + str(msg) +". Not able to create email accounts, aborting. [671][5009]")
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [startRestore]")
return 0
@@ -750,7 +750,7 @@ class backupUtilities:
cmd = shlex.split(command)
subprocess.call(cmd)
except BaseException, msg:
except BaseException as msg:
status = os.path.join(completPath, 'status')
logging.CyberCPLogFileWriter.statusWriter(status, str(msg) + " [736][5009]")
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [startRestore]")
@@ -760,7 +760,7 @@ class backupUtilities:
try:
p = Process(target=backupUtilities.startRestore, args=(backupName, dir,))
p.start()
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [initiateRestore]")
@staticmethod
@@ -797,13 +797,13 @@ class backupUtilities:
return [1, "None"]
except pexpect.TIMEOUT, msg:
except pexpect.TIMEOUT as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [sendKey]")
return [0, "TIMEOUT [sendKey]"]
except pexpect.EOF, msg:
except pexpect.EOF as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [sendKey]")
return [0, "EOF [sendKey]"]
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [sendKey]")
return [0, str(msg) + " [sendKey]"]
@@ -868,9 +868,9 @@ class backupUtilities:
return [0,sendKey[1]]
except pexpect.TIMEOUT, msg:
except pexpect.TIMEOUT as msg:
return [0, str(msg) + " [TIMEOUT setupSSHKeys]"]
except BaseException, msg:
except BaseException as msg:
return [0, str(msg) + " [setupSSHKeys]"]
@staticmethod
@@ -880,7 +880,7 @@ class backupUtilities:
return 1
else:
return 0
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[checkIfHostIsUp]")
@staticmethod
@@ -923,13 +923,13 @@ class backupUtilities:
subprocess.call(['kill', str(checkConn.pid)])
return [1, "None"]
except pexpect.TIMEOUT, msg:
except pexpect.TIMEOUT as msg:
logging.CyberCPLogFileWriter.writeToFile("Timeout "+IPAddress+ " [checkConnection]")
return [0, "371 Timeout while making connection to this server [checkConnection]"]
except pexpect.EOF, msg:
except pexpect.EOF as msg:
logging.CyberCPLogFileWriter.writeToFile("EOF "+IPAddress+ "[checkConnection]")
return [0, "374 Remote Server is not able to authenticate for transfer to initiate. [checkConnection]"]
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg)+" " +IPAddress+ " [checkConnection]")
return [0, "377 Remote Server is not able to authenticate for transfer to initiate. [checkConnection]"]
@@ -990,13 +990,13 @@ class backupUtilities:
return [1, "None"]
except pexpect.TIMEOUT, msg:
except pexpect.TIMEOUT as msg:
logging.CyberCPLogFileWriter.writeToFile("Timeout [verifyHostKey]")
return [0,"Timeout [verifyHostKey]"]
except pexpect.EOF, msg:
except pexpect.EOF as msg:
logging.CyberCPLogFileWriter.writeToFile("EOF [verifyHostKey]")
return [0,"EOF [verifyHostKey]"]
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [verifyHostKey]")
return [0,str(msg)+" [verifyHostKey]"]
@@ -1013,7 +1013,7 @@ class backupUtilities:
command = "sudo ssh -o StrictHostKeyChecking=no -p " + port + " -i /root/.ssh/cyberpanel root@" + IPAddress + ' "cat /root/.ssh/authorized_temp > /root/.ssh/authorized_keys"'
subprocess.call(shlex.split(command))
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [createBackupDir]")
return 0
@@ -1023,7 +1023,7 @@ class backupUtilities:
command = 'sudo ssh-keygen -R ' + IPAddress
subprocess.call(shlex.split(command))
return 1
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [host_key_verification]")
return 0
@@ -1039,9 +1039,9 @@ class backupUtilities:
return aliases
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [getAliases]")
print 0
print(0)
def submitBackupCreation(tempStoragePath, backupName, backupPath, backupDomain):
@@ -1150,7 +1150,7 @@ def submitBackupCreation(tempStoragePath, backupName, backupPath, backupDomain):
command = 'rm -f %s' % (result[2])
ProcessUtilities.executioner(command, 'cyberpanel')
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [submitBackupCreation]")
@@ -1163,7 +1163,7 @@ def cancelBackupCreation(backupCancellationDomain,fileName):
try:
os.kill(int(pid), signal.SIGKILL)
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [cancelBackupCreation]")
backupPath = "/home/" + backupCancellationDomain + "/backup/"
@@ -1172,21 +1172,21 @@ def cancelBackupCreation(backupCancellationDomain,fileName):
try:
os.remove(tempStoragePath + ".tar.gz")
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [cancelBackupCreation]")
try:
rmtree(tempStoragePath)
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [cancelBackupCreation]")
status = open(backupPath + 'status', "w")
status.write("Aborted manually. [1165][5009]")
status.close()
except BaseException,msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [cancelBackupCreation]")
print "0,"+str(msg)
print("0,"+str(msg))
def submitRestore(backupFile,dir):
try:
@@ -1194,21 +1194,21 @@ def submitRestore(backupFile,dir):
p = Process(target=backupUtilities.startRestore, args=(backupFile, dir,))
p.start()
print "1,None"
print("1,None")
except BaseException,msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [cancelBackupCreation]")
print "0,"+str(msg)
print("0,"+str(msg))
def submitDestinationCreation(ipAddress, password, port):
setupKeys = backupUtilities.setupSSHKeys(ipAddress, password, port)
if setupKeys[0] == 1:
backupUtilities.createBackupDir(ipAddress, port)
print "1,None"
print("1,None")
else:
print setupKeys[1]
print(setupKeys[1])
def getConnectionStatus(ipAddress):
@@ -1216,12 +1216,12 @@ def getConnectionStatus(ipAddress):
checkCon = backupUtilities.checkConnection(ipAddress)
if checkCon[0] == 1:
print "1,None"
print("1,None")
else:
print checkCon[1]
print(checkCon[1])
except BaseException, msg:
print str(msg)
except BaseException as msg:
print(str(msg))
def main():

View File

@@ -139,7 +139,7 @@ class cPanelImporter:
return 1
except BaseException, msg:
except BaseException as msg:
message = 'Failed to extract backup for file %s, error message: %s. [ExtractBackup]' % (
self.backupFile, str(msg))
logging.statusWriter(self.logFile, message, 1)
@@ -219,8 +219,8 @@ class cPanelImporter:
tWeb = Websites.objects.get(externalApp=self.externalApp)
self.externalApp = '%s%s' % (tWeb.externalApp, str(counter))
counter = counter + 1
print self.externalApp
except BaseException, msg:
print(self.externalApp)
except BaseException as msg:
logging.statusWriter(self.logFile, str(msg), 1)
time.sleep(2)
@@ -291,7 +291,7 @@ class cPanelImporter:
return 1
except BaseException, msg:
except BaseException as msg:
message = 'Failed to create main website from backup file %s, error message: %s.' % (
self.backupFile, str(msg))
logging.statusWriter(self.logFile, message, 1)
@@ -354,7 +354,7 @@ class cPanelImporter:
logging.statusWriter(self.logFile, message, 1)
for items in Domains:
print items.domain
print(items.domain)
## Starting Child-domains creation
@@ -469,13 +469,13 @@ class cPanelImporter:
message = 'Successfully created child domain.'
logging.statusWriter(self.logFile, message, 1)
except BaseException, msg:
except BaseException as msg:
message = 'Failed to create child domain from backup file %s, error message: %s. Moving on..' % (
self.backupFile, str(msg))
return 1
except BaseException, msg:
except BaseException as msg:
message = 'Failed to create child domain from backup file %s, error message: %s.' % (
self.backupFile, str(msg))
logging.statusWriter(self.logFile, message, 1)
@@ -578,7 +578,7 @@ class cPanelImporter:
else:
DNS.createDNSRecord(zone, RecordsData[0] + '.' + topLevelDomain , RecordsData[3], RecordsData[4].rstrip('.').rstrip('.\n'), 0,
RecordsData[1])
except BaseException, msg:
except BaseException as msg:
message = 'Failed while creating DNS entry for %s, error message: %s.' % (topLevelDomain, str(msg))
logging.statusWriter(self.logFile, message, 1)
@@ -587,7 +587,7 @@ class cPanelImporter:
return 1
except BaseException, msg:
except BaseException as msg:
message = 'Failed to create DNS records from file %s, error message: %s.' % (
self.backupFile, str(msg))
logging.statusWriter(self.logFile, message, 1)
@@ -607,7 +607,7 @@ class cPanelImporter:
return conn, cursor
except BaseException, msg:
except BaseException as msg:
message = 'Failed to connect to database, error message: %s. [ExtractBackup]' % (str(msg))
logging.statusWriter(self.logFile, message, 1)
return 0, 0
@@ -642,7 +642,7 @@ class cPanelImporter:
try:
cursor.execute("CREATE DATABASE `%s`" % (items.replace('.sql', '')))
except BaseException, msg:
except BaseException as msg:
message = 'Failed while restoring database %s from backup file %s, error message: %s' % (items.replace('.sql', ''), self.backupFile, str(msg))
logging.statusWriter(self.logFile, message, 1)
@@ -694,7 +694,7 @@ class cPanelImporter:
continue
try:
cursor.execute(items)
except BaseException, msg:
except BaseException as msg:
message = 'Failed while restoring database %s from backup file %s, error message: %s' % (
items.replace('.sql', ''), self.backupFile, str(msg))
logging.statusWriter(self.logFile, message, 1)
@@ -706,7 +706,7 @@ class cPanelImporter:
return 1
except BaseException, msg:
except BaseException as msg:
message = 'Failed to retore databases from file %s, error message: %s.' % (
self.backupFile, str(msg))
logging.statusWriter(self.logFile, message, 1)
@@ -869,7 +869,7 @@ class cPanelImporter:
message = 'Restore completed for %s.' % (finalEmailUsername)
logging.statusWriter(self.logFile, message, 1)
except BaseException, msg:
except BaseException as msg:
message = 'Failed to restore emails from archive file %s, For domain: %s. error message: %s. [ExtractBackup]' % (
self.backupFile, items, str(msg))
logging.statusWriter(self.logFile, message, 1)
@@ -883,7 +883,7 @@ class cPanelImporter:
return 1
except BaseException, msg:
except BaseException as msg:
message = 'Failed to restore emails from archive file %s, error message: %s. [ExtractBackup]' % (
self.backupFile, str(msg))
logging.statusWriter(self.logFile, message, 1)

View File

@@ -14,13 +14,13 @@ class CronUtil:
try:
f = open(cronPath, 'r').read()
print f
except BaseException, msg:
print "0,CyberPanel," + str(msg)
print(f)
except BaseException as msg:
print("0,CyberPanel," + str(msg))
return 1
except BaseException, msg:
print "0,CyberPanel," + str(msg)
except BaseException as msg:
print("0,CyberPanel," + str(msg))
@staticmethod
def saveCronChanges(externalApp, finalCron, line):
@@ -40,9 +40,9 @@ class CronUtil:
with open(cronPath, 'w') as file:
file.writelines(data)
print "1,None"
except BaseException, msg:
print "0," + str(msg)
print("1,None")
except BaseException as msg:
print("0," + str(msg))
@staticmethod
def remCronbyLine(externalApp, line):
@@ -68,9 +68,9 @@ class CronUtil:
counter = counter + 1
print "1," + removedLine
except BaseException, msg:
print "0," + str(msg)
print("1," + removedLine)
except BaseException as msg:
print("0," + str(msg))
@staticmethod
def addNewCron(externalApp, finalCron):
@@ -80,9 +80,9 @@ class CronUtil:
with open(CronPath, "a") as file:
file.write(finalCron + "\n")
print "1,None"
except BaseException, msg:
print "0," + str(msg)
print("1,None")
except BaseException as msg:
print("0," + str(msg))
@staticmethod
def CronPrem(mode):

View File

@@ -27,7 +27,7 @@ class CSF(multi.Thread):
self.installCSF()
elif self.installApp == 'removeCSF':
self.removeCSF()
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + ' [CSF.run]')
@staticmethod
@@ -354,7 +354,7 @@ class CSF(multi.Thread):
pass
return 1
except BaseException, msg:
except BaseException as msg:
try:
os.remove('csf.tgz')
os.removedirs('csf')
@@ -394,7 +394,7 @@ class CSF(multi.Thread):
subprocess.call(shlex.split(command))
return 1
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[removeCSF]")
@staticmethod
@@ -438,7 +438,7 @@ class CSF(multi.Thread):
return currentSettings
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [fetchCSFSettings]")
@staticmethod
@@ -448,11 +448,11 @@ class CSF(multi.Thread):
if status == 'enable':
command = 'csf -s'
subprocess.call(shlex.split(command))
print '1,None'
print('1,None')
else:
command = 'csf -f'
subprocess.call(shlex.split(command))
print '1,None'
print('1,None')
elif controller == 'testingMode':
data = open('/etc/csf/csf.conf', 'r').readlines()
@@ -468,11 +468,11 @@ class CSF(multi.Thread):
else:
writeToFile.writelines(items)
writeToFile.close()
print '1,None'
print('1,None')
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[changeStatus]")
print '0', str(msg)
print('0', str(msg))
@staticmethod
def modifyPorts(protocol, portsPath):
@@ -528,11 +528,11 @@ class CSF(multi.Thread):
except:
pass
print '1,None'
print('1,None')
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[modifyPorts]")
print '0', str(msg)
print('0', str(msg))
@staticmethod
def allowIP(ipAddress):
@@ -543,7 +543,7 @@ class CSF(multi.Thread):
command = 'sudo csf -a ' + ipAddress
ProcessUtilities.executioner(command)
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[allowIP]")
@staticmethod
@@ -556,7 +556,7 @@ class CSF(multi.Thread):
command = 'sudo csf -d ' + ipAddress
ProcessUtilities.executioner(command)
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[blockIP]")
@staticmethod
@@ -565,7 +565,7 @@ class CSF(multi.Thread):
command = 'sudo csf -g ' + ipAddress
ProcessUtilities.executioner(command)
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[checkIP]")

View File

@@ -380,7 +380,7 @@ class DNS:
command = 'sudo systemctl restart pdns'
ProcessUtilities.executioner(command)
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
"We had errors while creating DNS records for: " + domain + ". Error message: " + str(msg))
@@ -416,7 +416,7 @@ class DNS:
command = 'sudo systemctl restart pdns'
ProcessUtilities.executioner(command)
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
"We had errors while creating DKIM record for: " + domain + ". Error message: " + str(msg))
@@ -509,7 +509,7 @@ class DNS:
if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu:
command = 'sudo systemctl restart pdns'
ProcessUtilities.executioner(command)
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [createDNSRecord]")
@staticmethod

View File

@@ -16,12 +16,12 @@ class filemanager:
filemanager.write(fileKey)
filemanager.close()
print fileKey
print(fileKey)
except BaseException,msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [createTemporaryFile]")
print "0," + str(msg)
print("0," + str(msg))
def main():

View File

@@ -54,10 +54,10 @@ class findBWUsage:
writeMeta.writelines(str(newSeekPoint) + "\n")
writeMeta.close()
except OSError, msg:
except OSError as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [calculateBandwidth]")
return 0
except ValueError, msg:
except ValueError as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [calculateBandwidth]")
return 0
@@ -70,7 +70,7 @@ class findBWUsage:
try:
for directories in os.listdir("/home"):
findBWUsage.calculateBandwidth(directories)
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [startCalculations]")
return 0
@@ -110,10 +110,10 @@ class findBWUsage:
return [0, 0]
except OSError, msg:
except OSError as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [findDomainBW]")
return 0
except ValueError, msg:
except ValueError as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [findDomainBW]")
return 0
@@ -140,10 +140,10 @@ class findBWUsage:
print("###############################################")
except OSError, msg:
except OSError as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [changeSystemLanguage]")
return 0
except ValueError, msg:
except ValueError as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [changeSystemLanguage]")
return 0

View File

@@ -29,10 +29,10 @@ class FirewallUtilities:
logging.CyberCPLogFileWriter.writeToFile("Failed to apply rule: " + command + " Error #" + str(res))
return 0
except OSError, msg:
except OSError as msg:
logging.CyberCPLogFileWriter.writeToFile("Failed to apply rule: " + command + " Error: " + str(msg))
return 0
except ValueError, msg:
except ValueError as msg:
logging.CyberCPLogFileWriter.writeToFile("Failed to apply rule: " + command + " Error: " + str(msg), 1)
return 0
return 1
@@ -130,10 +130,10 @@ class FirewallUtilities:
command = 'sudo systemctl restart sshd'
ProcessUtilities.normalExecutioner(command)
print "1,None"
print("1,None")
except BaseException, msg:
print "0," + str(msg)
except BaseException as msg:
print("0," + str(msg))
@staticmethod
def addSSHKey(tempPath):
@@ -176,10 +176,10 @@ class FirewallUtilities:
if os.path.split(tempPath):
os.remove(tempPath)
print "1,None"
print("1,None")
except BaseException, msg:
print "0," + str(msg)
except BaseException as msg:
print("0," + str(msg))
@staticmethod
def deleteSSHKey(key):
@@ -199,10 +199,10 @@ class FirewallUtilities:
writeToFile.close()
print "1,None"
print("1,None")
except BaseException, msg:
print "0," + str(msg)
except BaseException as msg:
print("0," + str(msg))
def main():

View File

@@ -34,15 +34,15 @@ class FTPUtilities:
res = subprocess.call(cmd)
if res == 1:
print "Permissions not changed."
print("Permissions not changed.")
else:
print "User permissions setted."
print("User permissions setted.")
query = "INSERT INTO ftp_ftpuser (userid,passwd,homedir) VALUES ('" + username + "'" +","+"'"+password+"'"+","+"'"+path+"'"+");"
print query
print(query)
sql.mysqlUtilities.SendQuery(udb,upass, "ftp", query)
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [createNewFTPAccount]")
return 0
@@ -61,10 +61,10 @@ class FTPUtilities:
res = subprocess.call(cmd)
if res == 1:
print "Permissions not changed."
print("Permissions not changed.")
return 0
else:
print "User permissions setted."
print("User permissions setted.")
@@ -79,7 +79,7 @@ class FTPUtilities:
else:
return 1
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [createNewFTPAccount]")
return 0
@@ -95,7 +95,7 @@ class FTPUtilities:
return 1,'None'
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [ftpFunctions]")
return 0, str(msg)
@@ -140,7 +140,7 @@ class FTPUtilities:
path = "/home/" + domainName
if os.path.islink(path):
print "0, %s file is symlinked." % (path)
print("0, %s file is symlinked." % (path))
return 0
hash = hashlib.md5()
@@ -175,12 +175,12 @@ class FTPUtilities:
else:
raise BaseException("Exceeded maximum amount of FTP accounts allowed for the package.")
print "1,None"
print("1,None")
return 1,'None'
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [submitFTPCreation]")
print "0,"+str(msg)
print("0,"+str(msg))
return 0, str(msg)
@staticmethod
@@ -189,7 +189,7 @@ class FTPUtilities:
ftp = Users.objects.get(user=ftpUsername)
ftp.delete()
return 1,'None'
except BaseException, msg:
except BaseException as msg:
return 0, str(msg)
@staticmethod
@@ -203,7 +203,7 @@ class FTPUtilities:
ftp.save()
return 1, None
except BaseException, msg:
except BaseException as msg:
return 0,str(msg)
@staticmethod

View File

@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.shortcuts import render, HttpResponse
import json
@@ -30,7 +30,7 @@ class httpProc:
finalDic['status'] = status
finalDic['error_message'] = errorMessage
for key, value in data.iteritems():
for key, value in data.items():
finalDic[key] = value
finalJson = json.dumps(finalDic)

View File

@@ -29,10 +29,10 @@ class installUtilities:
print("###############################################")
print(" EPEL Repo Added ")
print("###############################################")
except OSError,msg:
except OSError as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [enableEPELRepo]")
return 0
except ValueError,msg:
except ValueError as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [enableEPELRepo]")
return 0
@@ -57,10 +57,10 @@ class installUtilities:
print(" Litespeed Repo Added ")
print("###############################################")
except OSError,msg:
except OSError as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [addLiteSpeedRepo]")
return 0
except ValueError,msg:
except ValueError as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [addLiteSpeedRepo]")
return 0
@@ -91,10 +91,10 @@ class installUtilities:
print(" Litespeed Installed ")
print("###############################################")
except OSError, msg:
except OSError as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [installLiteSpeed]")
return 0
except ValueError, msg:
except ValueError as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [installLiteSpeed]")
return 0
@@ -123,10 +123,10 @@ class installUtilities:
print(" Litespeed Started ")
print("###############################################")
except OSError, msg:
except OSError as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [startLiteSpeed]")
return 0
except ValueError, msg:
except ValueError as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [startLiteSpeed]")
return 0
@@ -144,10 +144,10 @@ class installUtilities:
ProcessUtilities.normalExecutioner(command)
except OSError, msg:
except OSError as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [reStartLiteSpeed]")
return 0
except ValueError, msg:
except ValueError as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [reStartLiteSpeed]")
return 0
return 1
@@ -163,10 +163,10 @@ class installUtilities:
return ProcessUtilities.executioner(command)
except OSError, msg:
except OSError as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [reStartLiteSpeed]")
return 0
except ValueError, msg:
except ValueError as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [reStartLiteSpeed]")
return 0
@@ -181,10 +181,10 @@ class installUtilities:
return ProcessUtilities.executioner(command)
except OSError, msg:
except OSError as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [reStartLiteSpeed]")
return 0
except ValueError, msg:
except ValueError as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [reStartLiteSpeed]")
return 0
@@ -211,10 +211,10 @@ class installUtilities:
print(" Litespeed Re-Started ")
print("###############################################")
except OSError, msg:
except OSError as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [reStartOpenLiteSpeed]")
return 0
except ValueError, msg:
except ValueError as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [reStartOpenLiteSpeed]")
return 0
return 1
@@ -233,7 +233,7 @@ class installUtilities:
writeDataToFile.close()
except IOError, msg:
except IOError as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [changePortTo80]")
return 0
@@ -267,13 +267,13 @@ class installUtilities:
except OSError, msg:
except OSError as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [installAllPHPVersion]")
return 0
except ValueError, msg:
except ValueError as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [installAllPHPVersion]")
@@ -306,7 +306,7 @@ class installUtilities:
writeDataToFile.close()
except IOError, msg:
except IOError as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [installAllPHPToLitespeed]")
return 0
@@ -357,10 +357,10 @@ class installUtilities:
print("###############################################")
except OSError, msg:
except OSError as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [removeWebServer]")
return 0
except ValueError, msg:
except ValueError as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [removeWebServer]")
return 0
@@ -385,17 +385,17 @@ class installUtilities:
print("###############################################")
sys.exit()
except OSError, msg:
except OSError as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [removeWebServer]")
return 0
except ValueError, msg:
except ValueError as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [removeWebServer]")
return 0
try:
shutil.rmtree(installUtilities.Server_root_path)
except BaseException,msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [removeWebServer]")
return 0
@@ -427,10 +427,10 @@ class installUtilities:
print("###############################################")
except OSError, msg:
except OSError as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [startMariaDB]")
return 0
except ValueError, msg:
except ValueError as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [startMariaDB]")
return 0
@@ -463,13 +463,13 @@ class installUtilities:
print("###############################################")
except OSError, msg:
except OSError as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [installMySQL]")
return 0
except ValueError, msg:
except ValueError as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [installMySQL]")
@@ -502,10 +502,10 @@ class installUtilities:
print(" MariaDB Addded to startup ")
print("###############################################")
except OSError, msg:
except OSError as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " Could not add mariadb to startup [installMySQL]")
return 0
except ValueError, msg:
except ValueError as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " Could not add mariadb to startup [installMySQL]")
return 0
@@ -562,18 +562,18 @@ class installUtilities:
if (securemysql.before.find("Thanks for using MariaDB!") > -1 or securemysql.after.find("Thanks for using MariaDB!")>-1):
return 1
except pexpect.EOF,msg:
except pexpect.EOF as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " Exception EOF [installMySQL]")
print("###########################Before########################################")
print securemysql.before
print(securemysql.before)
print("###########################After########################################")
print securemysql.after
print(securemysql.after)
print("########################################################################")
except BaseException,msg:
except BaseException as msg:
print("#############################Before#####################################")
print securemysql.before
print(securemysql.before)
print("############################After######################################")
print securemysql.after
print(securemysql.after)
print("########################################################################")
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[installMySQL]")

View File

@@ -37,8 +37,8 @@ class mailUtilities:
try:
smtpObj = smtplib.SMTP('localhost')
smtpObj.sendmail(sender, receivers, message)
print "Successfully sent email"
except BaseException, msg:
print("Successfully sent email")
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg))
@staticmethod
def AfterEffects(domain):
@@ -157,13 +157,13 @@ class mailUtilities:
emailLimits = EmailLimits(email=emailAcct)
emailLimits.save()
print "1,None"
print("1,None")
return 1,"None"
except BaseException,msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [createEmailAccount]")
print "0," + str(msg)
print("0," + str(msg))
return 0, str(msg)
@staticmethod
@@ -175,7 +175,7 @@ class mailUtilities:
return 1, 'None'
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [deleteEmailAccount]")
return 0, str(msg)
@@ -206,7 +206,7 @@ class mailUtilities:
changePass.password = newPassword
changePass.save()
return 0,'None'
except BaseException, msg:
except BaseException as msg:
return 0, str(msg)
@staticmethod
@@ -280,7 +280,7 @@ class mailUtilities:
return 1, "None"
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [setupDKIM:275]")
return 0, str(msg)
@@ -294,7 +294,7 @@ class mailUtilities:
command = "sudo cat " + path
return ProcessUtilities.executioner(command)
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [checkIfDKIMInstalled]")
return 0
@@ -306,12 +306,12 @@ class mailUtilities:
if result[0] == 0:
raise BaseException(result[1])
else:
print "1,None"
print("1,None")
except BaseException,msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [generateKeys]")
print "0," + str(msg)
print("0," + str(msg))
@staticmethod
def configureOpenDKIM():
@@ -361,18 +361,18 @@ milter_default_action = accept
command = "systemctl start postfix"
subprocess.call(shlex.split(command))
print "1,None"
print("1,None")
return
except OSError, msg:
except OSError as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [configureOpenDKIM]")
print "0," + str(msg)
print("0," + str(msg))
return
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [configureOpenDKIM]")
print "0," + str(msg)
print("0," + str(msg))
return
@staticmethod
@@ -398,7 +398,7 @@ milter_default_action = accept
command = "sudo chown -R cyberpanel:cyberpanel " + mailUtilities.cyberPanelHome
subprocess.call(shlex.split(command), stdout=FNULL)
except BaseException,msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [checkHome]")
@staticmethod
@@ -426,7 +426,7 @@ milter_default_action = accept
writeToFile.close()
return 1
except BaseException, msg:
except BaseException as msg:
writeToFile = open(mailUtilities.installLogPath, 'a')
writeToFile.writelines("Can not be installed.[404]\n")
writeToFile.close()
@@ -440,7 +440,7 @@ milter_default_action = accept
command = 'systemctl restart dovecot'
subprocess.call(shlex.split(command))
except BaseException,msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [restartServices]")
@staticmethod
@@ -469,7 +469,7 @@ milter_default_action = accept
writeToFile.close()
return 1
except BaseException, msg:
except BaseException as msg:
writeToFile = open(mailUtilities.spamassassinInstallLogPath, 'a')
writeToFile.writelines("Can not be installed.[404]\n")
writeToFile.close()
@@ -489,7 +489,7 @@ milter_default_action = accept
else:
return 1
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [checkIfSpamAssassinInstalled]")
return 0
@@ -552,17 +552,17 @@ milter_default_action = accept
ProcessUtilities.normalExecutioner(command)
print "1,None"
print("1,None")
return
except OSError, msg:
except OSError as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [configureSpamAssassin]")
print "0," + str(msg)
print("0," + str(msg))
return
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [configureSpamAssassin]")
print "0," + str(msg)
print("0," + str(msg))
return
@staticmethod
@@ -604,13 +604,13 @@ milter_default_action = accept
command = 'systemctl restart spamassassin'
subprocess.call(shlex.split(command))
print "1,None"
print("1,None")
return
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [saveSpamAssassinConfigs]")
print "0," + str(msg)
print("0," + str(msg))
@staticmethod
def savePolicyServerStatus(install):
@@ -656,13 +656,13 @@ milter_default_action = accept
command = 'systemctl restart postfix'
subprocess.call(shlex.split(command))
print "1,None"
print("1,None")
return
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [savePolicyServerStatus]")
print "0," + str(msg)
print("0," + str(msg))
def main():

View File

@@ -44,7 +44,7 @@ class modSec:
writeToFile.close()
return 1
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[installModSec]")
@staticmethod
@@ -101,13 +101,13 @@ modsecurity_rules_file /usr/local/lsws/conf/modsec/rules.conf
rule.write(initialRules)
rule.close()
print "1,None"
print("1,None")
return
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [installModSecConfigs]")
print "0," + str(msg)
print("0," + str(msg))
@staticmethod
def saveModSecConfigs(tempConfigPath):
@@ -152,7 +152,7 @@ modsecurity_rules_file /usr/local/lsws/conf/modsec/rules.conf
installUtilities.reStartLiteSpeed()
print "1,None"
print("1,None")
return
else:
confFile = os.path.join(virtualHostUtilities.Server_root, "conf/modsec.conf")
@@ -186,13 +186,13 @@ modsecurity_rules_file /usr/local/lsws/conf/modsec/rules.conf
installUtilities.reStartLiteSpeed()
print "1,None"
print("1,None")
return
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [saveModSecConfigs]")
print "0," + str(msg)
print("0," + str(msg))
@staticmethod
def saveModSecRules():
@@ -212,13 +212,13 @@ modsecurity_rules_file /usr/local/lsws/conf/modsec/rules.conf
installUtilities.reStartLiteSpeed()
print "1,None"
print("1,None")
return
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [saveModSecRules]")
print "0," + str(msg)
print("0," + str(msg))
@staticmethod
def setupComodoRules():
@@ -264,7 +264,7 @@ modsecurity_rules_file /usr/local/lsws/conf/modsec/rules.conf
return 1
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [setupComodoRules]")
return 0
@@ -275,7 +275,7 @@ modsecurity_rules_file /usr/local/lsws/conf/modsec/rules.conf
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
if modSec.setupComodoRules() == 0:
print '0, Unable to download Comodo Rules.'
print('0, Unable to download Comodo Rules.')
return
owaspRulesConf = """modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/modsecurity.conf
@@ -327,7 +327,7 @@ modsecurity_rules_file /usr/local/lsws/conf/modsec/rules.conf
conf.close()
installUtilities.reStartLiteSpeed()
print "1,None"
print("1,None")
return
else:
if os.path.exists('/usr/local/lsws/conf/comodo_litespeed'):
@@ -351,13 +351,13 @@ modsecurity_rules_file /usr/local/lsws/conf/modsec/rules.conf
subprocess.call(shlex.split(command))
installUtilities.reStartLiteSpeed()
print "1,None"
print("1,None")
return
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [installComodo]")
print "0," + str(msg)
print("0," + str(msg))
@staticmethod
def disableComodo():
@@ -377,22 +377,22 @@ modsecurity_rules_file /usr/local/lsws/conf/modsec/rules.conf
conf.close()
installUtilities.reStartLiteSpeed()
print "1,None"
print("1,None")
else:
try:
shutil.rmtree('/usr/local/lsws/conf/comodo_litespeed')
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + ' [disableComodo]')
installUtilities.reStartLiteSpeed()
print "1,None"
print("1,None")
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [disableComodo]")
print "0," + str(msg)
print("0," + str(msg))
@staticmethod
def setupOWASPRules():
@@ -418,7 +418,7 @@ modsecurity_rules_file /usr/local/lsws/conf/modsec/rules.conf
return 1
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [setupOWASPRules]")
return 0
@@ -427,7 +427,7 @@ modsecurity_rules_file /usr/local/lsws/conf/modsec/rules.conf
def installOWASP():
try:
if modSec.setupOWASPRules() == 0:
print '0, Unable to download OWASP Rules.'
print('0, Unable to download OWASP Rules.')
return
owaspRulesConf = """modsecurity_rules_file /usr/local/lsws/conf/modsec/owasp/modsecurity.conf
@@ -476,12 +476,12 @@ modsecurity_rules_file /usr/local/lsws/conf/modsec/owasp/rules/RESPONSE-999-EXCL
conf.close()
installUtilities.reStartLiteSpeed()
print "1,None"
print("1,None")
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [installOWASP]")
print "0," + str(msg)
print("0," + str(msg))
@staticmethod
def disableOWASP():
@@ -500,12 +500,12 @@ modsecurity_rules_file /usr/local/lsws/conf/modsec/owasp/rules/RESPONSE-999-EXCL
conf.close()
installUtilities.reStartLiteSpeed()
print "1,None"
print("1,None")
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [disableOWASP]")
print "0," + str(msg)
print("0," + str(msg))
@staticmethod
def disableRuleFile(fileName, packName):
@@ -534,12 +534,12 @@ modsecurity_rules_file /usr/local/lsws/conf/modsec/owasp/rules/RESPONSE-999-EXCL
installUtilities.reStartLiteSpeed()
print "1,None"
print("1,None")
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [disableRuleFile]")
print "0," + str(msg)
print("0," + str(msg))
@staticmethod
def enableRuleFile(fileName, packName):
@@ -567,12 +567,12 @@ modsecurity_rules_file /usr/local/lsws/conf/modsec/owasp/rules/RESPONSE-999-EXCL
installUtilities.reStartLiteSpeed()
print "1,None"
print("1,None")
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [enableRuleFile]")
print "0," + str(msg)
print("0," + str(msg))
def main():

View File

@@ -65,7 +65,7 @@ class mysqlUtilities:
return conn, cursor
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg))
return 0, 0
@@ -85,7 +85,7 @@ class mysqlUtilities:
return 1
except BaseException, msg:
except BaseException as msg:
mysqlUtilities.deleteDatabase(dbname, dbuser)
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[createDatabase]")
return 0
@@ -104,7 +104,7 @@ class mysqlUtilities:
return 1
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[createDBUser]")
return 0
@@ -122,7 +122,7 @@ class mysqlUtilities:
return 1
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[createDatabase]")
return 0
@@ -141,7 +141,7 @@ class mysqlUtilities:
return 1
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[deleteDatabase]")
return str(msg)
@@ -167,7 +167,7 @@ password=%s
writeToFile.write(cnfContent)
writeToFile.close()
os.chmod(cnfPath, 0600)
os.chmod(cnfPath, 0o600)
command = 'mysqldump --defaults-extra-file=/home/cyberpanel/.my.cnf --host=localhost ' + databaseName
cmd = shlex.split(command)
@@ -182,12 +182,12 @@ password=%s
"Database: " + databaseName + "could not be backed! [createDatabaseBackup]")
return 0
except subprocess.CalledProcessError, msg:
except subprocess.CalledProcessError as msg:
logging.CyberCPLogFileWriter.writeToFile(
"Database: " + databaseName + "could not be backed! Error: %s. [createDatabaseBackup]" % (str(msg)))
return 0
return 1
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[createDatabaseBackup]")
return 0
@@ -214,7 +214,7 @@ password=%s
writeToFile.write(cnfContent)
writeToFile.close()
os.chmod(cnfPath, 0600)
os.chmod(cnfPath, 0o600)
command = 'chown cyberpanel:cyberpanel %s' % (cnfPath)
subprocess.call(shlex.split(command))
@@ -247,7 +247,7 @@ password=%s
connection.close()
return 1
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[restoreDatabaseBackup]")
return 0
@@ -282,7 +282,7 @@ password=%s
return 1,'None'
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg))
return 0,str(msg)
@@ -299,7 +299,7 @@ password=%s
else:
return 0,result
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg))
return 0, str(msg)
@@ -383,7 +383,7 @@ password=%s
return data
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[showStatus]")
return 0
@@ -430,7 +430,7 @@ password=%s
return 1, None
except BaseException, msg:
except BaseException as msg:
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
command = 'sudo mv /etc/my.cnf.bak /etc/my.cnf'
else:
@@ -457,7 +457,7 @@ password=%s
##
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[showStatus]")
return 0
@@ -469,7 +469,7 @@ password=%s
return 1, None
except BaseException, msg:
except BaseException as msg:
command = 'sudo mv /etc/my.cnf.bak /etc/my.cnf'
subprocess.call(shlex.split(command))
logging.CyberCPLogFileWriter.writeToFile(str(msg))
@@ -517,7 +517,7 @@ password=%s
data['databases'] = json_data
return data
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[fetchDatabases]")
return 0
@@ -563,7 +563,7 @@ password=%s
data['tables'] = json_data
return data
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[fetchDatabases]")
return 0
@@ -584,7 +584,7 @@ password=%s
return data
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[fetchDatabases]")
return 0
@@ -644,7 +644,7 @@ password=%s
return data
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[fetchTableData]")
return 0
@@ -694,7 +694,7 @@ password=%s
return data
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[showStatus]")
return 0
@@ -722,7 +722,7 @@ password=%s
return 1
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[mysqlUtilities.changePassword]")
return 0
@@ -762,6 +762,6 @@ password=%s
return 1
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[mysqlUtilities.fetchuser]")
return 0

View File

@@ -1,7 +1,7 @@
import CyberCPLogFileWriter as logging
import subprocess
import shlex
import thread
import _thread
import installUtilities
import argparse
import os
@@ -43,7 +43,7 @@ class phpUtilities:
logging.CyberCPLogFileWriter.writeToFile("[Could not Install]")
installUtilities.installUtilities.reStartLiteSpeed()
return 0
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[installPHPExtension]")
@staticmethod
@@ -77,21 +77,21 @@ class phpUtilities:
installUtilities.installUtilities.reStartLiteSpeed()
return 0
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[unInstallPHPExtension]")
@staticmethod
def initiateInstall(extension):
try:
thread.start_new_thread(phpUtilities.installPHPExtension, (extension, extension))
except BaseException, msg:
_thread.start_new_thread(phpUtilities.installPHPExtension, (extension, extension))
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [initiateInstall]")
@staticmethod
def initiateRemoval(extension):
try:
thread.start_new_thread(phpUtilities.unInstallPHPExtension, (extension, extension))
except BaseException, msg:
_thread.start_new_thread(phpUtilities.unInstallPHPExtension, (extension, extension))
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [initiateRestore]")
@staticmethod
@@ -144,12 +144,12 @@ class phpUtilities:
installUtilities.installUtilities.reStartLiteSpeed()
print "1,None"
print("1,None")
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [savePHPConfigBasic]")
print "0,"+str(msg)
print("0,"+str(msg))
@staticmethod
def savePHPConfigAdvance(phpVers,tempPath):
@@ -162,11 +162,11 @@ class phpUtilities:
if os.path.exists(tempPath):
os.remove(tempPath)
print "1,None"
except BaseException, msg:
print("1,None")
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [savePHPConfigAdvance]")
print "0,"+str(msg)
print("0,"+str(msg))

View File

@@ -25,7 +25,7 @@ class ProcessUtilities(multi.Thread):
try:
if self.function == 'popen':
self.customPoen()
except BaseException, msg:
except BaseException as msg:
logging.writeToFile( str(msg) + ' [ApplicationInstaller.run]')
@staticmethod
@@ -38,7 +38,7 @@ class ProcessUtilities(multi.Thread):
if proc.name().find(ProcessUtilities.litespeedProcess) > -1:
finalListOfProcesses.append(proc.pid)
except BaseException,msg:
except BaseException as msg:
logging.writeToFile(
str(msg) + " [getLitespeedProcessNumber]")
return 0
@@ -64,7 +64,7 @@ class ProcessUtilities(multi.Thread):
else:
return 0
except subprocess.CalledProcessError,msg:
except subprocess.CalledProcessError as msg:
logging.writeToFile(str(msg) + "[restartLitespeed]")
@staticmethod
@@ -83,7 +83,7 @@ class ProcessUtilities(multi.Thread):
else:
return 0
except subprocess.CalledProcessError, msg:
except subprocess.CalledProcessError as msg:
logging.writeToFile(str(msg) + "[stopLitespeed]")
@staticmethod
@@ -94,10 +94,10 @@ class ProcessUtilities(multi.Thread):
return 1
else:
return 0
except subprocess.CalledProcessError, msg:
except subprocess.CalledProcessError as msg:
logging.writeToFile('%s. [ProcessUtilities.normalExecutioner]' % (str(msg)))
return 0
except BaseException, msg:
except BaseException as msg:
logging.writeToFile('%s. [ProcessUtilities.normalExecutioner.Base]' % (str(msg)))
return 0
@@ -156,7 +156,7 @@ class ProcessUtilities(multi.Thread):
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
sock.connect(ProcessUtilities.server_address)
return [sock, "None"]
except BaseException, msg:
except BaseException as msg:
if count == 3:
logging.writeToFile("Failed to connect to LSCPD socket, run 'systemctl restart lscpd' on command line to fix this issue.")
return [-1, str(msg)]
@@ -212,7 +212,7 @@ class ProcessUtilities(multi.Thread):
# ProcessUtilities.executioner(cmd)
return data
except BaseException, msg:
except BaseException as msg:
logging.writeToFile(str(msg) + " [sendCommand]")
return "0" + str(msg)
@@ -233,7 +233,7 @@ class ProcessUtilities(multi.Thread):
else:
return 0
except BaseException, msg:
except BaseException as msg:
logging.writeToFile(str(msg) + " [executioner]")
return 0
@@ -249,7 +249,7 @@ class ProcessUtilities(multi.Thread):
command = " ".join(command)
return ProcessUtilities.sendCommand(command, user)[:-1]
except BaseException, msg:
except BaseException as msg:
logging.writeToFile(str(msg) + "[outputExecutioner:188]")
def customPoen(self):
@@ -262,7 +262,7 @@ class ProcessUtilities(multi.Thread):
ProcessUtilities.sendCommand(command, self.extraArgs['user'])
return 1
except BaseException, msg:
except BaseException as msg:
logging.writeToFile(str(msg) + " [customPoen]")
@staticmethod
@@ -273,13 +273,13 @@ class ProcessUtilities(multi.Thread):
extraArgs['user'] = user
pu = ProcessUtilities("popen", extraArgs)
pu.start()
except BaseException, msg:
except BaseException as msg:
logging.writeToFile(str(msg) + " [popenExecutioner]")
@staticmethod
def BuildCommand(path, functionName, parameters):
execPath = "/usr/local/CyberCP/bin/python2 %s %s " % (path, functionName)
for key, value in parameters.iteritems():
for key, value in parameters.items():
execPath = execPath + ' --%s %s' % (key, value)
return execPath

View File

@@ -13,7 +13,7 @@ def generate_pass(length=14):
password = []
while len(password) < length:
key = choice(char_set.keys())
key = choice(list(char_set.keys()))
a_char = urandom(1)
if a_char in char_set[key]:
if check_prev_char(password, char_set[key]):

View File

@@ -25,7 +25,7 @@ class remoteBackup:
else:
return [0, data['error_message']]
except BaseException,msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [getKey]")
return [0,"Not able to fetch key from remote server, Error Message:" + str(msg)]
@@ -105,7 +105,7 @@ class remoteBackup:
writeToFile.writelines("completed[success]")
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [initiateRestore]")
@staticmethod
@@ -144,7 +144,7 @@ class remoteBackup:
pid.write(str(p.pid))
pid.close()
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [remoteRestore]")
return [0, msg]
@@ -164,7 +164,7 @@ class remoteBackup:
else:
return [0, data['error_message']]
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [postRemoteTransfer]")
return [0, msg]
@@ -210,7 +210,7 @@ class remoteBackup:
writeToFile.writelines("\n")
writeToFile.writelines("\n")
except BaseException,msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [214:startBackup]")
@@ -223,7 +223,7 @@ class remoteBackup:
subprocess.call(shlex.split(command), stdout=writeToFile)
os.remove(completedPathToSend)
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [startBackup]")
@staticmethod
@@ -308,7 +308,7 @@ class remoteBackup:
time.sleep(5)
#rmtree(dir)
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [backupProcess]")
@staticmethod
@@ -358,6 +358,6 @@ class remoteBackup:
return [1, None]
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [remoteTransfer]")
return [0, msg]

View File

@@ -30,7 +30,7 @@ class remoteTransferUtilities:
os.remove(pathToKey)
except:
pass
print "1,None"
print("1,None")
return
except:
pass
@@ -45,12 +45,12 @@ class remoteTransferUtilities:
os.remove(pathToKey)
except:
pass
print "1,None"
print("1,None")
return
except BaseException,msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile("For remote transfer, I am not able to write key to auth file, Error Message: "+str(msg))
print "0,"+"For remote transfer, I am not able to write key to auth file, Error Message: " + str(msg)
print("0,"+"For remote transfer, I am not able to write key to auth file, Error Message: " + str(msg))
## House keeping function to run remote backups
@staticmethod
@@ -110,7 +110,7 @@ class remoteTransferUtilities:
return
except BaseException, msg:
except BaseException as msg:
writeToFile = open(backupLogPath, "w+")
writeToFile.writelines(str(msg) + " [5010]" + "\n")
writeToFile.close()
@@ -168,7 +168,7 @@ class remoteTransferUtilities:
writeToFile.writelines("[" + time.strftime(
"%m.%d.%Y_%H-%M-%S") + "]" + "Failed to generate local backup for: " + virtualHost + "\n")
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [remoteTransferUtilities.backupProcess:173]")
pass
@@ -181,7 +181,7 @@ class remoteTransferUtilities:
#time.sleep(5)
# rmtree(dir)
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [backupProcess]")
@staticmethod
@@ -194,7 +194,7 @@ class remoteTransferUtilities:
os.remove(completedPathToSend)
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [startBackup]")
@staticmethod
@@ -236,7 +236,7 @@ class remoteTransferUtilities:
return
except BaseException, msg:
except BaseException as msg:
backupLogPath = backupDir + "/backup_log"
writeToFile = open(backupLogPath, "w+")
writeToFile.writelines(str(msg) + " [5010]" + "\n")
@@ -320,7 +320,7 @@ class remoteTransferUtilities:
"%m.%d.%Y_%H-%M-%S") + "]" + " Backup Restore complete\n")
writeToFile.writelines("completed[success]")
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [remoteTransferUtilities.startRestore]")

View File

@@ -99,7 +99,7 @@ class Renew:
virtualHostUtilities.issueSSL(website.domain, website.path,
website.master.adminEmail)
except BaseException, msg:
except BaseException as msg:
logging.writeToFile(str(msg) + '. Renew.SSLObtainer')

View File

@@ -8,8 +8,8 @@ class serverLogs:
try:
logFile = open(fileName,'w')
logFile.close()
print "1,None"
except BaseException,msg:
print("1,None")
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[cleanLogFile]")
def main():

View File

@@ -28,11 +28,11 @@ class sslUtilities:
if items.find("}") > -1:
return 0
if items.find(virtualHostName) > -1 and sslCheck == 1:
data = filter(None, items.split(" "))
data = [_f for _f in items.split(" ") if _f]
if data[1] == virtualHostName:
return 1
except BaseException,msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [IO Error with main config file [checkIfSSLMap]]")
return 0
@@ -44,7 +44,7 @@ class sslUtilities:
if items.find("listener SSL") > -1:
return 1
except BaseException,msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [IO Error with main config file [checkSSLListener]]")
return str(msg)
return 0
@@ -58,7 +58,7 @@ class sslUtilities:
return [1, withWWW, withoutWWW]
except BaseException, msg:
except BaseException as msg:
return [0, "347 " + str(msg) + " [issueSSLForDomain]"]
@staticmethod
@@ -182,7 +182,7 @@ class sslUtilities:
writeSSLConfig.close()
return 1
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [installSSLForDomain]]")
return 0
else:
@@ -203,7 +203,7 @@ class sslUtilities:
chilDomain = ChildDomains.objects.get(domain=virtualHostName)
externalApp = chilDomain.master.externalApp
DocumentRoot = ' DocumentRoot ' + chilDomain.path + '\n'
except BaseException, msg:
except BaseException as msg:
website = Websites.objects.get(domain=virtualHostName)
externalApp = website.externalApp
DocumentRoot = ' DocumentRoot /home/' + virtualHostName + '/public_html\n'
@@ -255,7 +255,7 @@ class sslUtilities:
confFile.close()
return 1
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [installSSLForDomain]")
return 0
@@ -335,7 +335,7 @@ class sslUtilities:
else:
return 0
except BaseException,msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [Failed to obtain SSL. [obtainSSLForADomain]]")
return 0
@@ -362,6 +362,6 @@ def issueSSLForDomain(domain, adminEmail, sslpath, aliasDomain = None):
else:
return [0, "210 Failed to install SSL for domain. [issueSSLForDomain]"]
except BaseException,msg:
except BaseException as msg:
return [0, "347 "+ str(msg)+ " [issueSSLForDomain]"]

View File

@@ -49,7 +49,7 @@ class tuning:
dataToReturn['enableGzipCompress'] = data[1]
return dataToReturn
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [fetchTuningDetails]")
return 0
@@ -71,7 +71,7 @@ class tuning:
return dataToReturn
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [fetchTuningDetails]")
return 0
@@ -125,11 +125,11 @@ class tuning:
writeDataToFile.close()
print "1,None"
except BaseException, msg:
print("1,None")
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [saveTuningDetails]")
print "0," + str(msg)
print("0," + str(msg))
else:
try:
datas = open("/usr/local/lsws/conf/httpd_config.xml").readlines()
@@ -173,11 +173,11 @@ class tuning:
else:
writeDataToFile.writelines(items)
writeDataToFile.close()
print "1,None"
except BaseException, msg:
print("1,None")
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [saveTuningDetails]")
print "0," + str(msg)
print("0," + str(msg))
@staticmethod
@@ -223,7 +223,7 @@ class tuning:
dataToReturn['procHardLimit'] = data[1]
return dataToReturn
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [fetchPHPDetails]")
return 0
@@ -248,7 +248,7 @@ class tuning:
break
return dataToReturn
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [fetchPHPDetails]")
return 0
@@ -308,11 +308,11 @@ class tuning:
writeDataToFile.close()
print "1,None"
except BaseException, msg:
print("1,None")
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [saveTuningDetails]")
print "0,"+str(msg)
print("0,"+str(msg))
else:
try:
path = "/usr/local/lsws/conf/httpd_config.xml"
@@ -377,12 +377,12 @@ class tuning:
writeDataToFile.close()
print "1,None"
print("1,None")
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [saveTuningDetails]")
print "0," + str(msg)
print("0," + str(msg))
def main():

View File

@@ -26,11 +26,11 @@ class Upgrade:
@staticmethod
def stdOut(message, do_exit=0):
print("\n\n")
print ("[" + time.strftime(
"%m.%d.%Y_%H-%M-%S") + "] #########################################################################\n")
print("[" + time.strftime("%m.%d.%Y_%H-%M-%S") + "] " + message + "\n")
print ("[" + time.strftime(
"%m.%d.%Y_%H-%M-%S") + "] #########################################################################\n")
print(("[" + time.strftime(
"%m.%d.%Y_%H-%M-%S") + "] #########################################################################\n"))
print(("[" + time.strftime("%m.%d.%Y_%H-%M-%S") + "] " + message + "\n"))
print(("[" + time.strftime(
"%m.%d.%Y_%H-%M-%S") + "] #########################################################################\n"))
if do_exit:
os._exit(0)
@@ -123,7 +123,7 @@ class Upgrade:
writeToFile.writelines(varTmp)
writeToFile.close()
except BaseException, msg:
except BaseException as msg:
Upgrade.stdOut(str(msg) + " [mountTemp]", 0)
@staticmethod
@@ -232,7 +232,7 @@ class Upgrade:
## Write secret phrase
rString = ''.join([random.choice(string.ascii_letters + string.digits) for n in xrange(32)])
rString = ''.join([random.choice(string.ascii_letters + string.digits) for n in range(32)])
data = open('phpmyadmin/config.sample.inc.php', 'r').readlines()
@@ -253,7 +253,7 @@ class Upgrade:
os.chdir(cwd)
except BaseException, msg:
except BaseException as msg:
Upgrade.stdOut(str(msg) + " [download_install_phpmyadmin]", 0)
@staticmethod
@@ -401,7 +401,7 @@ class Upgrade:
os.chdir(cwd)
except BaseException, msg:
except BaseException as msg:
Upgrade.stdOut(str(msg) + " [downoad_and_install_raindloop]", 0)
return 1
@@ -425,7 +425,7 @@ class Upgrade:
pass
return (version_number + "." + version_build + ".tar.gz")
except BaseException, msg:
except BaseException as msg:
Upgrade.stdOut(str(msg) + ' [downloadLink]')
os._exit(0)
@@ -456,7 +456,7 @@ class Upgrade:
env_path = '/usr/local/CyberCP'
subprocess.call(['virtualenv', env_path])
activate_this = os.path.join(env_path, 'bin', 'activate_this.py')
execfile(activate_this, dict(__file__=activate_this))
exec(compile(open(activate_this, "rb").read(), activate_this, 'exec'), dict(__file__=activate_this))
##
@@ -467,7 +467,7 @@ class Upgrade:
Upgrade.executioner(command, 'Setting up VirtualEnv [Two]', 0)
Upgrade.stdOut('Virtual enviroment for CyberPanel successfully installed.')
except OSError, msg:
except OSError as msg:
Upgrade.stdOut(str(msg) + " [setupVirtualEnv]", 0)
@staticmethod
@@ -499,7 +499,7 @@ class Upgrade:
command = "chmod +x /usr/local/CyberCP/cli/cyberPanel.py"
Upgrade.executioner(command, 'CLI Permissions', 0)
except OSError, msg:
except OSError as msg:
Upgrade.stdOut(str(msg) + " [setupCLI]")
return 0
@@ -559,7 +559,7 @@ class Upgrade:
cursor = conn.cursor()
return conn, cursor
except BaseException, msg:
except BaseException as msg:
Upgrade.stdOut(str(msg))
return 0, 0
@@ -661,7 +661,7 @@ class Upgrade:
except:
pass
except OSError, msg:
except OSError as msg:
Upgrade.stdOut(str(msg) + " [applyLoginSystemMigrations]")
@staticmethod
@@ -847,7 +847,7 @@ class Upgrade:
except:
pass
except OSError, msg:
except OSError as msg:
Upgrade.stdOut(str(msg) + " [applyLoginSystemMigrations]")
@staticmethod
@@ -1315,7 +1315,7 @@ class Upgrade:
command = 'sudo yum install git -y'
Upgrade.executioner(command, 'installGit', 0)
except BaseException, msg:
except BaseException as msg:
pass
@staticmethod
@@ -1497,7 +1497,7 @@ CSRF_COOKIE_SECURE = True
try:
command = "pip install pydns"
Upgrade.executioner(command, 'Install PyDNS', 1)
except OSError, msg:
except OSError as msg:
Upgrade.stdOut(str(msg) + " [installPYDNS]")
return 0
@@ -1508,7 +1508,7 @@ CSRF_COOKIE_SECURE = True
Upgrade.executioner(command, 'Install tldextract', 1)
command = "pip install bcrypt"
Upgrade.executioner(command, 'Install tldextract', 1)
except OSError, msg:
except OSError as msg:
Upgrade.stdOut(str(msg) + " [installTLDExtract]")
return 0
@@ -1563,7 +1563,7 @@ CSRF_COOKIE_SECURE = True
Upgrade.stdOut("LSCPD successfully installed!")
except BaseException, msg:
except BaseException as msg:
Upgrade.stdOut(str(msg) + " [installLSCPD]")
@staticmethod
@@ -1692,7 +1692,7 @@ CSRF_COOKIE_SECURE = True
Upgrade.stdOut("Permissions updated.")
except BaseException, msg:
except BaseException as msg:
Upgrade.stdOut(str(msg) + " [installLSCPD]")
@staticmethod
@@ -1916,7 +1916,7 @@ failovermethod=priority
Upgrade.stdOut("Dovecot upgraded.")
except BaseException, msg:
except BaseException as msg:
Upgrade.stdOut(str(msg) + " [upgradeDovecot]")
@staticmethod
@@ -1974,7 +1974,7 @@ failovermethod=priority
env_path = '/usr/local/CyberPanel/p3'
subprocess.call(['virtualenv', env_path])
activate_this = os.path.join(env_path, 'bin', 'activate_this.py')
execfile(activate_this, dict(__file__=activate_this))
exec(compile(open(activate_this, "rb").read(), activate_this, 'exec'), dict(__file__=activate_this))
command = "pip3 install --ignore-installed -r %s" % ('/usr/local/CyberCP/WebTerminal/requirments.txt')
Upgrade.executioner(command, 0)
@@ -1995,7 +1995,7 @@ failovermethod=priority
env_path = '/usr/local/CyberPanel/p3'
subprocess.call(['virtualenv', env_path])
activate_this = os.path.join(env_path, 'bin', 'activate_this.py')
execfile(activate_this, dict(__file__=activate_this))
exec(compile(open(activate_this, "rb").read(), activate_this, 'exec'), dict(__file__=activate_this))
command = "pip3 install --ignore-installed -r %s" % ('/usr/local/CyberCP/WebTerminal/requirments.txt')
Upgrade.executioner(command, 0)

View File

@@ -16,7 +16,7 @@ class UpgradeCritical:
return 1
else:
return 0
except BaseException, msg:
except BaseException as msg:
return 0
@staticmethod

View File

@@ -57,7 +57,7 @@ class vhost:
cmd = shlex.split(command)
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [addingUsers]")
@staticmethod
@@ -83,7 +83,7 @@ class vhost:
cmd = shlex.split(command)
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
except OSError, msg:
except OSError as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [27 Not able create to directories for virtual host [createDirectories]]")
return [0, "[27 Not able to directories for virtual host [createDirectories]]"]
@@ -95,7 +95,7 @@ class vhost:
cmd = shlex.split(command)
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
except OSError, msg:
except OSError as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [33 Not able to directories for virtual host [createDirectories]]")
return [0, "[33 Not able to directories for virtual host [createDirectories]]"]
@@ -121,7 +121,7 @@ class vhost:
cmd = shlex.split(command)
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
except OSError, msg:
except OSError as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [39 Not able to directories for virtual host [createDirectories]]")
return [0, "[39 Not able to directories for virtual host [createDirectories]]"]
@@ -129,7 +129,7 @@ class vhost:
try:
## For configuration files permissions will be changed later globally.
os.makedirs(confPath)
except OSError, msg:
except OSError as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [45 Not able to directories for virtual host [createDirectories]]")
return [0, "[45 Not able to directories for virtual host [createDirectories]]"]
@@ -146,13 +146,13 @@ class vhost:
cmd = shlex.split(command)
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
except IOError, msg:
except IOError as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [createDirectories]]")
return [0, "[45 Not able to directories for virtual host [createDirectories]]"]
return [1, 'None']
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [createDirectories]")
return [0, str(msg)]
@@ -174,7 +174,7 @@ class vhost:
cmd = shlex.split(command)
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [finalizeVhostCreation]")
@staticmethod
@@ -232,7 +232,7 @@ class vhost:
confFile.write(currentConf)
confFile.close()
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [IO Error with per host config file [perHostVirtualConf]]")
return 0
@@ -252,7 +252,7 @@ class vhost:
confFile.write(currentConf)
confFile.close()
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [IO Error with per host config file [perHostVirtualConf]]")
return 0
@@ -277,7 +277,7 @@ class vhost:
writeDataToFile.writelines(items)
return 1
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg))
return 0
@@ -298,7 +298,7 @@ class vhost:
writeDataToFile.close()
return [1,"None"]
except BaseException,msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "223 [IO Error with main config file [createConfigInMainVirtualHostFile]]")
return [0,"223 [IO Error with main config file [createConfigInMainVirtualHostFile]]"]
else:
@@ -310,7 +310,7 @@ class vhost:
writeDataToFile.close()
return [1, "None"]
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + "223 [IO Error with main config file [createConfigInMainVirtualHostFile]]")
return [0, "223 [IO Error with main config file [createConfigInMainVirtualHostFile]]"]
@@ -356,7 +356,7 @@ class vhost:
command = "sudo rm -rf /home/vmail/" + virtualHostName
subprocess.call(shlex.split(command))
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [Not able to remove virtual host configuration from main configuration file.]")
return 0
return 1
@@ -398,7 +398,7 @@ class vhost:
command = "sudo rm -rf /home/vmail/" + virtualHostName
subprocess.call(shlex.split(command))
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [Not able to remove virtual host configuration from main configuration file.]")
return 0
@@ -451,7 +451,7 @@ class vhost:
ApacheVhost.DeleteApacheVhost(virtualHostName)
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [Not able to remove virtual host configuration from main configuration file.]")
return 0
@@ -460,14 +460,14 @@ class vhost:
virtualHostPath = "/home/" + virtualHostName
try:
shutil.rmtree(virtualHostPath)
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [Not able to remove virtual host directory from /home continuing..]")
try:
confPath = vhost.Server_root + "/conf/vhosts/" + virtualHostName
shutil.rmtree(confPath)
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [Not able to remove virtual host configuration directory from /conf ]")
@@ -484,7 +484,7 @@ class vhost:
writeDataToFile.close()
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [Not able to remove virtual host configuration from main configuration file.]")
return 0
@@ -507,7 +507,7 @@ class vhost:
php = PHPManager.getPHPString(phpVersion)
if not os.path.exists("/usr/local/lsws/lsphp" + str(php) + "/bin/lsphp"):
print 0, 'This PHP version is not available on your CyberPanel.'
print(0, 'This PHP version is not available on your CyberPanel.')
return [0, "[This PHP version is not available on your CyberPanel. [changePHP]"]
writeDataToFile = open(vhFile, "w")
@@ -535,12 +535,12 @@ class vhost:
command = "systemctl restart php%s-php-fpm" % (php)
ProcessUtilities.normalExecutioner(command)
print "1,None"
print("1,None")
return 1,'None'
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [IO Error with per host config file [changePHP]")
print 0,str(msg)
print(0,str(msg))
return [0, str(msg) + " [IO Error with per host config file [changePHP]"]
else:
try:
@@ -549,7 +549,7 @@ class vhost:
php = PHPManager.getPHPString(phpVersion)
if not os.path.exists("/usr/local/lsws/lsphp" + str(php) + "/bin/lsphp"):
print 0, 'This PHP version is not available on your CyberPanel.'
print(0, 'This PHP version is not available on your CyberPanel.')
return [0, "[This PHP version is not available on your CyberPanel. [changePHP]"]
writeDataToFile = open(vhFile, "w")
@@ -573,19 +573,19 @@ class vhost:
except:
pass
print "1,None"
print("1,None")
return 1, 'None'
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [IO Error with per host config file [changePHP]]")
print 0, str(msg)
print(0, str(msg))
return [0, str(msg) + " [IO Error with per host config file [changePHP]]"]
@staticmethod
def addRewriteRules(virtualHostName, fileName=None):
try:
pass
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [IO Error with per host config file [changePHP]]")
return 0
@@ -599,7 +599,7 @@ class vhost:
return 1
return 0
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [IO Error with per host config file [checkIfRewriteEnabled]]")
return 0
@@ -610,12 +610,12 @@ class vhost:
path = "/home/" + domainName + "/logs/" + domainName + ".access_log"
if not os.path.exists("/home/" + domainName + "/logs"):
print "0,0"
print("0,0")
bwmeta = "/home/" + domainName + "/logs/bwmeta"
if not os.path.exists(path):
print "0,0"
print("0,0")
if os.path.exists(bwmeta):
try:
@@ -630,20 +630,20 @@ class vhost:
percentage = float(100) / float(totalAllowed)
percentage = float(percentage) * float(inMB)
except:
print "0,0"
print("0,0")
if percentage > 100.0:
percentage = 100
print str(inMB) + "," + str(percentage)
print(str(inMB) + "," + str(percentage))
else:
print "0,0"
except OSError, msg:
print("0,0")
except OSError as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [findDomainBW]")
print "0,0"
except ValueError, msg:
print("0,0")
except ValueError as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [findDomainBW]")
print "0,0"
print("0,0")
@staticmethod
def permissionControl(path):
@@ -651,7 +651,7 @@ class vhost:
command = 'sudo chown -R cyberpanel:cyberpanel ' + path
cmd = shlex.split(command)
res = subprocess.call(cmd)
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg))
@staticmethod
@@ -663,7 +663,7 @@ class vhost:
res = subprocess.call(cmd)
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg))
@staticmethod
@@ -671,7 +671,7 @@ class vhost:
try:
alias = aliasDomains.objects.get(aliasDomain=aliasDomain)
return 1
except BaseException, msg:
except BaseException as msg:
return 0
@staticmethod
@@ -682,7 +682,7 @@ class vhost:
return 1
return 0
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [checkIfSSLAliasExists]")
return 1
@@ -699,7 +699,7 @@ class vhost:
if (items.find("listener SSL") > -1):
sslCheck = 1
if items.find(masterDomain) > -1 and items.find('map') > -1 and sslCheck == 1:
data = filter(None, items.split(" "))
data = [_f for _f in items.split(" ") if _f]
if data[1] == masterDomain:
if vhost.checkIfSSLAliasExists(data, aliasDomain) == 0:
writeToFile.writelines(items.rstrip('\n') + ", " + aliasDomain + "\n")
@@ -712,7 +712,7 @@ class vhost:
writeToFile.close()
installUtilities.installUtilities.reStartLiteSpeed()
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [createAliasSSLMap]")
## Child Domain Functions
@@ -734,7 +734,7 @@ class vhost:
cmd = shlex.split(command)
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [finalizeDomainCreation]")
@staticmethod
@@ -751,14 +751,14 @@ class vhost:
command = "chown " + virtualHostUser + ":" + virtualHostUser + " " + path
cmd = shlex.split(command)
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
except OSError, msg:
except OSError as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + "329 [Not able to create directories for virtual host [createDirectoryForDomain]]")
try:
## For configuration files permissions will be changed later globally.
os.makedirs(confPath)
except OSError, msg:
except OSError as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + "335 [Not able to create directories for virtual host [createDirectoryForDomain]]")
return [0, "[344 Not able to directories for virtual host [createDirectoryForDomain]]"]
@@ -766,7 +766,7 @@ class vhost:
try:
## For configuration files permissions will be changed later globally.
file = open(completePathToConfigFile, "w+")
except IOError, msg:
except IOError as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [createDirectoryForDomain]]")
return [0, "[351 Not able to directories for virtual host [createDirectoryForDomain]]"]
@@ -803,7 +803,7 @@ class vhost:
confFile.write(currentConf)
confFile.close()
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [IO Error with per host config file [perHostDomainConf]]")
return 0
@@ -826,7 +826,7 @@ class vhost:
confFile.write(currentConf)
confFile.close()
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [IO Error with per host config file [perHostDomainConf]]")
return 0
@@ -852,7 +852,7 @@ class vhost:
return [1, "None"]
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + "223 [IO Error with main config file [createConfigInMainDomainHostFile]]")
return [0, "223 [IO Error with main config file [createConfigInMainDomainHostFile]]"]
@@ -863,7 +863,7 @@ class vhost:
writeDataToFile.writelines(configFile)
writeDataToFile.close()
return [1, "None"]
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + "223 [IO Error with main config file [createConfigInMainDomainHostFile]]")
return [0, "223 [IO Error with main config file [createConfigInMainDomainHostFile]]"]

View File

@@ -262,7 +262,7 @@ class virtualHostUtilities:
return 1, 'None'
except BaseException, msg:
except BaseException as msg:
vhost.deleteVirtualHostConfigurations(virtualHostName)
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [createVirtualHost]")
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, str(msg) + " [404]")
@@ -275,18 +275,18 @@ class virtualHostUtilities:
retValues = sslUtilities.issueSSLForDomain(virtualHost, adminEmail, path)
if retValues[0] == 0:
print "0," + str(retValues[1])
print("0," + str(retValues[1]))
logging.CyberCPLogFileWriter.writeToFile(str(retValues[1]))
return 0, str(retValues[1])
installUtilities.installUtilities.reStartLiteSpeed()
print "1,None"
print("1,None")
return 1, None
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [issueSSL]")
print "0," + str(msg)
print("0," + str(msg))
return 0, str(msg)
@staticmethod
@@ -294,7 +294,7 @@ class virtualHostUtilities:
try:
if os.path.islink(fileName):
print "0, %s file is symlinked." % (fileName)
print("0, %s file is symlinked." % (fileName))
return 0
numberOfTotalLines = int(ProcessUtilities.outputExecutioner('wc -l %s' % (fileName), externalApp).split(" ")[0])
@@ -318,12 +318,12 @@ class virtualHostUtilities:
startingAndEnding = "'" + str(start) + "," + str(end) + "p'"
command = "sed -n " + startingAndEnding + " " + fileName
data = ProcessUtilities.outputExecutioner(command, externalApp)
print data
print(data)
return data
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [getAccessLogs]")
print "1,None"
print("1,None")
return "1,None"
@staticmethod
@@ -331,7 +331,7 @@ class virtualHostUtilities:
try:
if os.path.islink(fileName):
print "0, %s file is symlinked." % (fileName)
print("0, %s file is symlinked." % (fileName))
return 0
numberOfTotalLines = int(
@@ -356,12 +356,12 @@ class virtualHostUtilities:
startingAndEnding = "'" + str(start) + "," + str(end) + "p'"
command = "sed -n " + startingAndEnding + " " + fileName
data = ProcessUtilities.outputExecutioner(command, externalApp)
print data
print(data)
return data
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [getErrorLogs]")
print "1,None"
print("1,None")
return "1,None"
@staticmethod
@@ -379,19 +379,19 @@ class virtualHostUtilities:
installUtilities.installUtilities.reStartLiteSpeed()
print "1,None"
print("1,None")
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [saveVHostConfigs]")
print "0," + str(msg)
print("0," + str(msg))
@staticmethod
def saveRewriteRules(virtualHost, fileName, tempPath):
try:
if os.path.islink(fileName):
print "0, .htaccess file is symlinked."
print("0, .htaccess file is symlinked.")
return 0
vhost.addRewriteRules(virtualHost, fileName)
@@ -406,12 +406,12 @@ class virtualHostUtilities:
except:
pass
print "1,None"
print("1,None")
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [saveRewriteRules]")
print "0," + str(msg)
print("0," + str(msg))
@staticmethod
def installWordPress(domainName, finalPath, virtualHostUser, dbName, dbUser, dbPassword):
@@ -430,12 +430,12 @@ class virtualHostUtilities:
if dirFiles[0] == ".well-known":
pass
else:
print "0,Target directory should be empty before installation, otherwise data loss could occur."
print("0,Target directory should be empty before installation, otherwise data loss could occur.")
return
elif len(dirFiles) == 0:
pass
else:
print "0,Target directory should be empty before installation, otherwise data loss could occur."
print("0,Target directory should be empty before installation, otherwise data loss could occur.")
return
## Get wordpress
@@ -514,10 +514,10 @@ class virtualHostUtilities:
installUtilities.installUtilities.reStartLiteSpeed()
print "1,None"
print("1,None")
except BaseException, msg:
except BaseException as msg:
# remove the downloaded files
try:
@@ -534,7 +534,7 @@ class virtualHostUtilities:
cmd = shlex.split(command)
res = subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
print "0," + str(msg)
print("0," + str(msg))
return
@staticmethod
@@ -559,7 +559,7 @@ class virtualHostUtilities:
background.start()
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + ' [installJoomla]')
@staticmethod
@@ -584,7 +584,7 @@ class virtualHostUtilities:
retValues = sslUtilities.issueSSLForDomain(virtualHost, adminEmail, path)
if retValues[0] == 0:
print "0," + str(retValues[1])
print("0," + str(retValues[1]))
return 0, retValues[1]
## removing old certs for lscpd
@@ -629,13 +629,13 @@ class virtualHostUtilities:
cmd = shlex.split(command)
subprocess.call(cmd)
print "1,None"
print("1,None")
return 1, 'None'
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [issueSSLForHostName]")
print "0," + str(msg)
print("0," + str(msg))
return 0, str(msg)
@staticmethod
@@ -650,7 +650,7 @@ class virtualHostUtilities:
retValues = sslUtilities.issueSSLForDomain(virtualHost, adminEmail, path)
if retValues[0] == 0:
print "0," + str(retValues[1])
print("0," + str(retValues[1]))
return 0, retValues[1]
## MailServer specific functions
@@ -732,13 +732,13 @@ class virtualHostUtilities:
p = Process(target=mailUtilities.restartServices, args=())
p.start()
print "1,None"
print("1,None")
return 1, 'None'
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [issueSSLForHostName]")
print "0," + str(msg)
print("0," + str(msg))
return 0, str(msg)
@staticmethod
@@ -749,7 +749,7 @@ class virtualHostUtilities:
DNS.dnsTemplate(aliasDomain, admin)
if vhost.checkIfAliasExists(aliasDomain) == 1:
print "0, This domain already exists as vHost or Alias."
print("0, This domain already exists as vHost or Alias.")
return
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
@@ -762,7 +762,7 @@ class virtualHostUtilities:
if items.find("listener") > -1 and items.find("Default") > -1:
listenerTrueCheck = 1
if items.find(' ' + masterDomain) > -1 and items.find('map') > -1 and listenerTrueCheck == 1:
data = filter(None, items.split(" "))
data = [_f for _f in items.split(" ") if _f]
if data[1] == masterDomain:
writeToFile.writelines(items.rstrip('\n') + ", " + aliasDomain + "\n")
listenerTrueCheck = 0
@@ -791,14 +791,14 @@ class virtualHostUtilities:
retValues = sslUtilities.issueSSLForDomain(masterDomain, administratorEmail, sslPath, aliasDomain)
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
if retValues[0] == 0:
print "0," + str(retValues[1])
print("0," + str(retValues[1]))
return
else:
vhost.createAliasSSLMap(confPath, masterDomain, aliasDomain)
else:
retValues = sslUtilities.issueSSLForDomain(masterDomain, administratorEmail, sslPath, aliasDomain)
if retValues[0] == 0:
print "0," + str(retValues[1])
print("0," + str(retValues[1]))
return
website = Websites.objects.get(domain=masterDomain)
@@ -806,11 +806,11 @@ class virtualHostUtilities:
newAlias = aliasDomains(master=website, aliasDomain=aliasDomain)
newAlias.save()
print "1,None"
print("1,None")
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [createAlias]")
print "0," + str(msg)
print("0," + str(msg))
@staticmethod
def issueAliasSSL(masterDomain, aliasDomain, sslPath, administratorEmail):
@@ -821,21 +821,21 @@ class virtualHostUtilities:
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
confPath = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf")
if retValues[0] == 0:
print "0," + str(retValues[1])
print("0," + str(retValues[1]))
return
else:
vhost.createAliasSSLMap(confPath, masterDomain, aliasDomain)
else:
if retValues[0] == 0:
print "0," + str(retValues[1])
print("0," + str(retValues[1]))
return
print "1,None"
print("1,None")
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [issueAliasSSL]")
print "0," + str(msg)
print("0," + str(msg))
@staticmethod
def deleteAlias(masterDomain, aliasDomain):
@@ -850,7 +850,7 @@ class virtualHostUtilities:
for items in data:
if items.find(masterDomain) > -1 and items.find('map') > -1:
data = filter(None, items.split(" "))
data = [_f for _f in items.split(" ") if _f]
if data[1] == masterDomain:
length = len(data)
for i in range(3, length):
@@ -879,10 +879,10 @@ class virtualHostUtilities:
delAlias = aliasDomains.objects.get(aliasDomain=aliasDomain)
delAlias.delete()
print "1,None"
except BaseException, msg:
print("1,None")
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [deleteAlias]")
print "0," + str(msg)
print("0," + str(msg))
else:
try:
@@ -903,10 +903,10 @@ class virtualHostUtilities:
alias = aliasDomains.objects.get(aliasDomain=aliasDomain)
alias.delete()
print "1,None"
except BaseException, msg:
print("1,None")
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [deleteAlias]")
print "0," + str(msg)
print("0," + str(msg))
@staticmethod
def changeOpenBasedir(domainName, openBasedirValue):
@@ -954,10 +954,10 @@ class virtualHostUtilities:
writeToFile.close()
installUtilities.installUtilities.reStartLiteSpeed()
print "1,None"
except BaseException, msg:
print("1,None")
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [changeOpenBasedir]")
print "0," + str(msg)
print("0," + str(msg))
else:
try:
confPath = virtualHostUtilities.Server_root + "/conf/vhosts/" + domainName
@@ -1007,10 +1007,10 @@ class virtualHostUtilities:
writeToFile.close()
installUtilities.installUtilities.reStartLiteSpeed()
print "1,None"
except BaseException, msg:
print("1,None")
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [changeOpenBasedir]")
print "0," + str(msg)
print("0," + str(msg))
@staticmethod
def saveSSL(virtualHost, keyPath, certPath):
@@ -1045,12 +1045,12 @@ class virtualHostUtilities:
cmd = shlex.split(command)
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
print "1,None"
print("1,None")
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [saveSSL]")
print "0," + str(msg)
print("0," + str(msg))
@staticmethod
def createDomain(masterDomain, virtualHostName, phpVersion, path, ssl, dkimCheck, openBasedir, owner, apache,
@@ -1191,7 +1191,7 @@ class virtualHostUtilities:
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, 'Domain successfully created. [200]')
return 1, "None"
except BaseException, msg:
except BaseException as msg:
numberOfWebsites = Websites.objects.count() + ChildDomains.objects.count()
vhost.deleteCoreConf(virtualHostName, numberOfWebsites)
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, str(msg) + ". [404]")
@@ -1209,13 +1209,13 @@ class virtualHostUtilities:
delWebsite.delete()
installUtilities.installUtilities.reStartLiteSpeed()
print "1,None"
print("1,None")
return 1, 'None'
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [deleteDomain]")
print "0," + str(msg)
print("0," + str(msg))
return 0, str(msg)
@staticmethod
@@ -1278,7 +1278,7 @@ class virtualHostUtilities:
installUtilities.installUtilities.reStartLiteSpeed()
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, 'Successfully converted. [200]')
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, '%s[404]' % str(msg))
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [switchServer]")
@@ -1310,7 +1310,7 @@ class virtualHostUtilities:
res = subprocess.call(cmd)
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg))
@staticmethod
@@ -1322,7 +1322,7 @@ class virtualHostUtilities:
res = subprocess.call(cmd)
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg))

View File

@@ -62,7 +62,7 @@ class WebsiteManager:
Data = {'packageList': packagesName, "owernList": adminNames, 'phps': phps}
return render(request, 'websiteFunctions/createWebsite.html', Data)
except BaseException, msg:
except BaseException as msg:
return HttpResponse(str(msg))
def modifyWebsite(self, request=None, userID=None, data=None):
@@ -77,7 +77,7 @@ class WebsiteManager:
phps = PHPManager.findPHPVersions()
return render(request, 'websiteFunctions/modifyWebsite.html', {'websiteList': websitesName, 'phps': phps})
except BaseException, msg:
except BaseException as msg:
return HttpResponse(str(msg))
def deleteWebsite(self, request=None, userID=None, data=None):
@@ -89,7 +89,7 @@ class WebsiteManager:
websitesName = ACLManager.findAllSites(currentACL, userID)
return render(request, 'websiteFunctions/deleteWebsite.html', {'websiteList': websitesName})
except BaseException, msg:
except BaseException as msg:
return HttpResponse(str(msg))
def siteState(self, request=None, userID=None, data=None):
@@ -102,7 +102,7 @@ class WebsiteManager:
websitesName = ACLManager.findAllSites(currentACL, userID)
return render(request, 'websiteFunctions/suspendWebsite.html', {'websiteList': websitesName})
except BaseException, msg:
except BaseException as msg:
return HttpResponse(str(msg))
def listWebsites(self, request=None, userID=None, data=None):
@@ -111,7 +111,7 @@ class WebsiteManager:
pagination = self.websitePagination(currentACL, userID)
return render(request, 'websiteFunctions/listWebsites.html', {"pagination": pagination})
except BaseException, msg:
except BaseException as msg:
return HttpResponse(str(msg))
def listCron(self, request=None, userID=None, data=None):
@@ -119,7 +119,7 @@ class WebsiteManager:
currentACL = ACLManager.loadedACL(userID)
websitesName = ACLManager.findAllSites(currentACL, userID)
return render(request, 'websiteFunctions/listCron.html', {'websiteList': websitesName})
except BaseException, msg:
except BaseException as msg:
return HttpResponse(str(msg))
def domainAlias(self, request=None, userID=None, data=None):
@@ -143,7 +143,7 @@ class WebsiteManager:
'path': path,
'noAlias': noAlias
})
except BaseException, msg:
except BaseException as msg:
return HttpResponse(str(msg))
def submitWebsiteCreation(self, userID=None, data=None):
@@ -212,7 +212,7 @@ class WebsiteManager:
return HttpResponse(json_data)
except BaseException, msg:
except BaseException as msg:
data_ret = {'status': 0, 'createWebSiteStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
@@ -270,7 +270,7 @@ class WebsiteManager:
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
except BaseException, msg:
except BaseException as msg:
data_ret = {'status': 0, 'createWebSiteStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
@@ -293,7 +293,7 @@ class WebsiteManager:
final_json = json.dumps({'status': 1, 'fetchStatus': 1, 'error_message': "None", "data": json_data})
return HttpResponse(final_json)
except BaseException, msg:
except BaseException as msg:
final_dic = {'status': 0, 'fetchStatus': 0, 'error_message': str(msg)}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
@@ -303,7 +303,7 @@ class WebsiteManager:
currentACL = ACLManager.loadedACL(userID)
try:
json_data = self.searchWebsitesJson(currentACL, userID, data['patternAdded'])
except BaseException, msg:
except BaseException as msg:
tempData = {}
tempData['page'] = 1
return self.getFurtherAccounts(userID, tempData)
@@ -313,7 +313,7 @@ class WebsiteManager:
'pagination': pagination}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
except BaseException, msg:
except BaseException as msg:
dic = {'status': 1, 'listWebSiteStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(dic)
return HttpResponse(json_data)
@@ -328,7 +328,7 @@ class WebsiteManager:
'pagination': pagination}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
except BaseException, msg:
except BaseException as msg:
dic = {'status': 1, 'listWebSiteStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(dic)
return HttpResponse(json_data)
@@ -358,7 +358,7 @@ class WebsiteManager:
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
except BaseException, msg:
except BaseException as msg:
data_ret = {'status': 0, 'websiteDeleteStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
@@ -383,7 +383,7 @@ class WebsiteManager:
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
except BaseException, msg:
except BaseException as msg:
data_ret = {'status': 0, 'websiteDeleteStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
@@ -423,7 +423,7 @@ class WebsiteManager:
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
except BaseException, msg:
except BaseException as msg:
data_ret = {'websiteStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
@@ -491,7 +491,7 @@ class WebsiteManager:
final_json = json.dumps(data_ret)
return HttpResponse(final_json)
except BaseException, msg:
except BaseException as msg:
dic = {'status': 0, 'modifyStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(dic)
return HttpResponse(json_data)
@@ -543,7 +543,7 @@ class WebsiteManager:
final_json = json.dumps(data_ret)
return HttpResponse(final_json)
except BaseException, msg:
except BaseException as msg:
dic = {'status': 0, 'error_message': str(msg)}
json_data = json.dumps(dic)
return HttpResponse(json_data)
@@ -591,7 +591,7 @@ class WebsiteManager:
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
except BaseException, msg:
except BaseException as msg:
data_ret = {'status': 0, 'saveStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
@@ -633,7 +633,7 @@ class WebsiteManager:
output = ProcessUtilities.outputExecutioner(execPath)
bwData = output.split(",")
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg))
bwData = [0, 0]
@@ -710,7 +710,7 @@ class WebsiteManager:
output = ProcessUtilities.outputExecutioner(execPath)
bwData = output.split(",")
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg))
bwData = [0, 0]
@@ -1121,7 +1121,7 @@ class WebsiteManager:
data_ret = {'getWebsiteCron': 1, "user": website.externalApp, "crons": crons}
final_json = json.dumps(data_ret)
return HttpResponse(final_json)
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg))
dic = {'getWebsiteCron': 0, 'error_message': str(msg)}
json_data = json.dumps(dic)
@@ -1185,8 +1185,8 @@ class WebsiteManager:
"line": line}
final_json = json.dumps(data_ret)
return HttpResponse(final_json)
except BaseException, msg:
print msg
except BaseException as msg:
print(msg)
dic = {'getWebsiteCron': 0, 'error_message': str(msg)}
json_data = json.dumps(dic)
return HttpResponse(json_data)
@@ -1236,7 +1236,7 @@ class WebsiteManager:
json_data = json.dumps(dic)
return HttpResponse(json_data)
except BaseException, msg:
except BaseException as msg:
dic = {'getWebsiteCron': 0, 'error_message': str(msg)}
json_data = json.dumps(dic)
return HttpResponse(json_data)
@@ -1278,7 +1278,7 @@ class WebsiteManager:
return HttpResponse(json_data)
except BaseException, msg:
except BaseException as msg:
dic = {'remCronbyLine': 0, 'error_message': str(msg)}
json_data = json.dumps(dic)
return HttpResponse(json_data)
@@ -1334,7 +1334,7 @@ class WebsiteManager:
return HttpResponse(json_data)
except BaseException, msg:
except BaseException as msg:
dic = {'addNewCron': 0, 'error_message': str(msg)}
json_data = json.dumps(dic)
return HttpResponse(json_data)
@@ -1386,7 +1386,7 @@ class WebsiteManager:
except BaseException, msg:
except BaseException as msg:
data_ret = {'createAliasStatus': 0, 'error_message': str(msg), "existsStatus": 0}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
@@ -1423,7 +1423,7 @@ class WebsiteManager:
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
except BaseException, msg:
except BaseException as msg:
data_ret = {'sslStatus': 0, 'error_message': str(msg), "existsStatus": 0}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
@@ -1458,7 +1458,7 @@ class WebsiteManager:
return HttpResponse(json_data)
except BaseException, msg:
except BaseException as msg:
data_ret = {'deleteAlias': 0, 'error_message': str(msg), "existsStatus": 0}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
@@ -1484,7 +1484,7 @@ class WebsiteManager:
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
except BaseException, msg:
except BaseException as msg:
data_ret = {'status': 0, 'changeOpenBasedir': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
@@ -1501,7 +1501,7 @@ class WebsiteManager:
return render(request, 'websiteFunctions/installWordPress.html', {'domainName': self.domain})
except BaseException, msg:
except BaseException as msg:
return HttpResponse(str(msg))
def installWordpress(self, userID=None, data=None):
@@ -1543,7 +1543,7 @@ class WebsiteManager:
return HttpResponse(json_data)
except BaseException, msg:
except BaseException as msg:
data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
@@ -1580,7 +1580,7 @@ class WebsiteManager:
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
except BaseException, msg:
except BaseException as msg:
data_ret = {'abort': 1, 'installStatus': 0, 'installationProgress': "0", 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
@@ -1596,7 +1596,7 @@ class WebsiteManager:
return ACLManager.loadError()
return render(request, 'websiteFunctions/installJoomla.html', {'domainName': self.domain})
except BaseException, msg:
except BaseException as msg:
return HttpResponse(str(msg))
def installJoomla(self, userID=None, data=None):
@@ -1627,7 +1627,7 @@ class WebsiteManager:
statusFile = open(tempStatusPath, 'w')
statusFile.writelines('Setting up paths,0')
statusFile.close()
os.chmod(tempStatusPath, 0777)
os.chmod(tempStatusPath, 0o777)
finalPath = ""
@@ -1738,7 +1738,7 @@ class WebsiteManager:
## Installation ends
except BaseException, msg:
except BaseException as msg:
data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
@@ -1794,7 +1794,7 @@ IdentityFile /home/%s/.ssh/%s
return render(request, 'websiteFunctions/setupGit.html',
{'domainName': self.domain, 'deploymentKey': deploymentKey, 'installed': 0})
except BaseException, msg:
except BaseException as msg:
return HttpResponse(str(msg))
def setupGitRepo(self, userID=None, data=None):
@@ -1831,7 +1831,7 @@ IdentityFile /home/%s/.ssh/%s
return HttpResponse(json_data)
except BaseException, msg:
except BaseException as msg:
data_ret = {'installStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
@@ -1849,7 +1849,7 @@ IdentityFile /home/%s/.ssh/%s
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
except BaseException, msg:
except BaseException as msg:
data_ret = {'pulled': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
@@ -1882,7 +1882,7 @@ IdentityFile /home/%s/.ssh/%s
return HttpResponse(json_data)
except BaseException, msg:
except BaseException as msg:
data_ret = {'status': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
@@ -1916,7 +1916,7 @@ IdentityFile /home/%s/.ssh/%s
return HttpResponse(json_data)
except BaseException, msg:
except BaseException as msg:
data_ret = {'status': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
@@ -1932,7 +1932,7 @@ IdentityFile /home/%s/.ssh/%s
return ACLManager.loadError()
return render(request, 'websiteFunctions/installPrestaShop.html', {'domainName': self.domain})
except BaseException, msg:
except BaseException as msg:
return HttpResponse(str(msg))
def prestaShopInstall(self, userID=None, data=None):
@@ -1977,7 +1977,7 @@ IdentityFile /home/%s/.ssh/%s
## Installation ends
except BaseException, msg:
except BaseException as msg:
data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
@@ -2022,7 +2022,7 @@ IdentityFile /home/%s/.ssh/%s
return self.submitWebsiteCreation(admin.pk, data)
except BaseException, msg:
except BaseException as msg:
data_ret = {'createWebSiteStatus': 0, 'error_message': str(msg), "existsStatus": 0}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
@@ -2039,7 +2039,7 @@ IdentityFile /home/%s/.ssh/%s
f = open(ipFile)
ipData = f.read()
ipAddress = ipData.split('\n', 1)[0]
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile("Failed to read machine IP, error:" + str(msg))
ipAddress = "192.168.100.1"
@@ -2074,7 +2074,7 @@ IdentityFile /home/%s/.ssh/%s
f = open(ipFile)
ipData = f.read()
ipAddress = ipData.split('\n', 1)[0]
except BaseException, msg:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile("Failed to read machine IP, error:" + str(msg))
ipAddress = "192.168.100.1"
@@ -2178,7 +2178,7 @@ IdentityFile /home/%s/.ssh/%s
json_data = json.dumps(data)
return HttpResponse(json_data)
except BaseException, msg:
except BaseException as msg:
data_ret = {'status': 0, 'saveStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
@@ -2294,7 +2294,7 @@ IdentityFile /home/%s/.ssh/%s
return render(request, 'websiteFunctions/sshAccess.html',
{'domainName': self.domain, 'externalApp': externalApp})
except BaseException, msg:
except BaseException as msg:
return HttpResponse(str(msg))
def saveSSHAccessChanges(self, userID=None, data=None):
@@ -2319,7 +2319,7 @@ IdentityFile /home/%s/.ssh/%s
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
except BaseException, msg:
except BaseException as msg:
data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)