diff --git a/ApachController/ApacheController.py b/ApachController/ApacheController.py index f9fca1b8e..3d55587d4 100755 --- a/ApachController/ApacheController.py +++ b/ApachController/ApacheController.py @@ -81,7 +81,7 @@ LoadModule mpm_event_module modules/mod_mpm_event.so return 1 else: return 0 - except BaseException, msg: + except BaseException as msg: message = "%s. [%s]" % (str(msg), '[ApacheController.checkIfApacheInstalled]') logging.CyberCPLogFileWriter.writeToFile(message) @@ -94,7 +94,7 @@ LoadModule mpm_event_module modules/mod_mpm_event.so return 0 else: return 1 - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) return 0 @@ -157,7 +157,7 @@ LoadModule mpm_event_module modules/mod_mpm_event.so return 1 - except BaseException, msg: + except BaseException as msg: return str(msg) @staticmethod @@ -302,5 +302,5 @@ LoadModule mpm_event_module modules/mod_mpm_event.so return [0,result] return [1, 'None'] - except BaseException, msg: + except BaseException as msg: return [0, str(msg)] \ No newline at end of file diff --git a/ApachController/ApacheVhosts.py b/ApachController/ApacheVhosts.py index 5775771c3..846d47590 100755 --- a/ApachController/ApacheVhosts.py +++ b/ApachController/ApacheVhosts.py @@ -144,7 +144,7 @@ class ApacheVhost: ProcessUtilities.normalExecutioner(command) return [1, 'None'] - except BaseException, msg: + except BaseException as msg: return [0, str(msg)] @staticmethod @@ -172,7 +172,7 @@ class ApacheVhost: confFile.close() return [1, 'None'] - except BaseException, msg: + except BaseException as msg: return [0, str(msg)] @staticmethod @@ -183,7 +183,7 @@ class ApacheVhost: confFile.write("REWRITERULE ^(.*)$ HTTP://apachebackend/$1 [P]") confFile.close() return [1, 'None'] - except BaseException, msg: + except BaseException as msg: return [0, str(msg)] @staticmethod @@ -256,7 +256,7 @@ class ApacheVhost: ProcessUtilities.normalExecutioner(command) return [1, 'None'] - except BaseException, msg: + except BaseException as msg: return [0, str(msg)] @staticmethod @@ -285,7 +285,7 @@ class ApacheVhost: command = "systemctl restart httpd" ProcessUtilities.normalExecutioner(command) - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg)) @staticmethod @@ -300,7 +300,7 @@ class ApacheVhost: confFile.write(currentConf) confFile.close() - except BaseException, msg: + except BaseException as msg: logging.writeToFile( str(msg) + " [IO Error with per host config file [ApacheVhosts.perHostVirtualConf]]") @@ -383,6 +383,6 @@ class ApacheVhost: ProcessUtilities.normalExecutioner(command) return 1 - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg)) return 1 \ No newline at end of file diff --git a/ApachController/BackupUtil.py b/ApachController/BackupUtil.py index 19f76e88d..418b861e6 100644 --- a/ApachController/BackupUtil.py +++ b/ApachController/BackupUtil.py @@ -14,7 +14,7 @@ class BackupUtil: return 1 else: return 0 - except BaseException, msg: + except BaseException as msg: return 0 @staticmethod @@ -25,9 +25,9 @@ class BackupUtil: try: smtpObj = smtplib.SMTP('127.0.0.1') smtpObj.sendmail(sender, receivers, message) - print "Successfully sent email" - except BaseException, msg: - print "Error: unable to send email %s" % str(msg) + print("Successfully sent email") + except BaseException as msg: + print("Error: unable to send email %s" % str(msg)) @staticmethod def SyncHome(): diff --git a/CLManager/CLManagerMain.py b/CLManager/CLManagerMain.py index d476c7b05..a90439e6f 100644 --- a/CLManager/CLManagerMain.py +++ b/CLManager/CLManagerMain.py @@ -28,7 +28,7 @@ class CLManagerMain(multi.Thread): elif self.function == 'enableOrDisable': self.enableOrDisable() - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + ' [ContainerManager.run]') def renderC(self): @@ -77,7 +77,7 @@ class CLManagerMain(multi.Thread): execPath = execPath + " --function submitCageFSInstall" ProcessUtilities.outputExecutioner(execPath) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, str(msg) + ' [404].', 1) def findWebsitesJson(self, currentACL, userID, pageNumber): @@ -144,7 +144,7 @@ class CLManagerMain(multi.Thread): 'pagination': pagination, 'default': default} 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) @@ -160,7 +160,7 @@ class CLManagerMain(multi.Thread): for items in websites: command = '/usr/sbin/cagefsctl --disable %s' % (items.externalApp) ProcessUtilities.executioner(command) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) def fetchPackages(self, currentACL): diff --git a/CLManager/CLPackages.py b/CLManager/CLPackages.py index 951acbee7..8c625e97a 100755 --- a/CLManager/CLPackages.py +++ b/CLManager/CLPackages.py @@ -20,7 +20,7 @@ class CLinuxPackages: try: clPackage = CLPackages.objects.get(owner=itemPackage) statement = '%s %s' % (pwd.getpwnam(items.externalApp).pw_uid, clPackage.name) - print statement + print(statement) except: pass @@ -28,7 +28,7 @@ class CLinuxPackages: @staticmethod def listPackages(): for items in CLPackages.objects.all(): - print items.name + print(items.name) @staticmethod def userIDPackage(user): @@ -36,7 +36,7 @@ class CLinuxPackages: itemPackage = website.package try: clPackage = CLPackages.objects.get(owner=itemPackage) - print clPackage + print(clPackage) except: pass @@ -48,7 +48,7 @@ class CLinuxPackages: try: clPackage = CLPackages.objects.get(owner=itemPackage) if clPackage.name == package: - print pwd.getpwnam(items.externalApp).pw_uid + print(pwd.getpwnam(items.externalApp).pw_uid) except: pass diff --git a/CLManager/CageFS.py b/CLManager/CageFS.py index 1fb87ff24..a0516b9c4 100644 --- a/CLManager/CageFS.py +++ b/CLManager/CageFS.py @@ -37,7 +37,7 @@ class CageFS: logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, "Packages successfully installed.[200]\n", 1) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, str(msg) + ' [404].', 1) def main(): diff --git a/CLManager/admin.py b/CLManager/admin.py index 13be29d96..4c33e0ec3 100644 --- a/CLManager/admin.py +++ b/CLManager/admin.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.contrib import admin diff --git a/CLManager/apps.py b/CLManager/apps.py index 1f97e1e94..a627ea6f3 100644 --- a/CLManager/apps.py +++ b/CLManager/apps.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.apps import AppConfig diff --git a/CLManager/models.py b/CLManager/models.py index cdbab13b0..22cd0633f 100644 --- a/CLManager/models.py +++ b/CLManager/models.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models from packages.models import Package diff --git a/CLManager/tests.py b/CLManager/tests.py index 5982e6bcd..f067dcaac 100644 --- a/CLManager/tests.py +++ b/CLManager/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.test import TestCase diff --git a/CLManager/views.py b/CLManager/views.py index e02a3a040..8dcbd53e8 100644 --- a/CLManager/views.py +++ b/CLManager/views.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.shortcuts import redirect, HttpResponse from loginSystem.views import loadLoginPage @@ -43,7 +43,7 @@ def submitCageFSInstall(request): json_data = json.dumps(data_ret) 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) @@ -104,7 +104,7 @@ def enableOrDisable(request): - 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) @@ -169,7 +169,7 @@ def submitCreatePackage(request): 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) @@ -213,7 +213,7 @@ def deleteCLPackage(request): 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) @@ -266,7 +266,7 @@ def saveSettings(request): 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) @@ -352,7 +352,7 @@ def getUsageData(request): final_json = json.dumps(finalData) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'error_message': str(msg), 'cpu': 0, 'memory':0} json_data = json.dumps(data_ret) return HttpResponse(json_data) \ No newline at end of file diff --git a/CyberCP/secMiddleware.py b/CyberCP/secMiddleware.py index 3efed4d2b..91c456634 100755 --- a/CyberCP/secMiddleware.py +++ b/CyberCP/secMiddleware.py @@ -48,7 +48,7 @@ class secMiddleware: try: #logging.writeToFile(request.body) data = json.loads(request.body) - for key, value in data.iteritems(): + for key, value in data.items(): if request.path.find('gitNotify') > -1: break @@ -93,7 +93,7 @@ class secMiddleware: final_dic = {'error_message': "Data supplied is not accepted.", "errorMessage": "Data supplied is not accepted."} final_json = json.dumps(final_dic) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg)) response = self.get_response(request) return response diff --git a/IncBackups/IncBackups.py b/IncBackups/IncBackups.py index 792a8fd6e..d8c812921 100644 --- a/IncBackups/IncBackups.py +++ b/IncBackups/IncBackups.py @@ -155,7 +155,7 @@ class IncJobs(multi.Thread): metaFileXML.append(dnsRecordsXML) - except BaseException, msg: + except BaseException as msg: logging.statusWriter(self.statusPath, '%s. [158:prepMeta]' % (str(msg)), 1) ## Email accounts XML @@ -176,7 +176,7 @@ class IncJobs(multi.Thread): emailRecordsXML.append(emailRecordXML) metaFileXML.append(emailRecordsXML) - except BaseException, msg: + except BaseException as msg: logging.writeToFile(self.statusPath, '%s. [warning:179:prepMeta]' % (str(msg)), 1) ## Email meta generated! @@ -196,7 +196,7 @@ class IncJobs(multi.Thread): metaFile = open(metaPath, 'w') metaFile.write(xmlpretty) metaFile.close() - os.chmod(metaPath, 0640) + os.chmod(metaPath, 0o640) ## meta generated @@ -211,7 +211,7 @@ class IncJobs(multi.Thread): return 1 - except BaseException, msg: + except BaseException as msg: logging.statusWriter(self.statusPath, "%s [207][5009]" % (str(msg)), 1) return 0 @@ -239,7 +239,7 @@ class IncJobs(multi.Thread): logging.statusWriter(self.statusPath, 'Data for %s backed to %s.' % (self.website.domain, self.backupDestinations), 1) return 1 - except BaseException, msg: + except BaseException as msg: logging.statusWriter(self.statusPath,'%s. [IncJobs.backupData.223][5009]' % str(msg), 1) return 0 @@ -271,7 +271,7 @@ class IncJobs(multi.Thread): destination=self.backupDestinations) newSnapshot.save() return 1 - except BaseException, msg: + except BaseException as msg: logging.statusWriter(self.statusPath,'%s. [IncJobs.backupDatabases.269][5009]' % str(msg), 1) return 0 @@ -304,7 +304,7 @@ class IncJobs(multi.Thread): logging.statusWriter(self.statusPath, 'Emails for %s backed to %s.' % (self.website.domain, self.backupDestinations), 1) return 1 - except BaseException, msg: + except BaseException as msg: logging.statusWriter(self.statusPath,'%s. [IncJobs.backupDatabases.269][5009]' % str(msg), 1) return 0 @@ -323,7 +323,7 @@ class IncJobs(multi.Thread): logging.statusWriter(self.statusPath, 'Repo %s initiated for %s.' % (self.backupDestinations, self.website.domain), 1) return 1 - except BaseException, msg: + except BaseException as msg: logging.statusWriter(self.statusPath,'%s. [IncJobs.initiateRepo.47][5009]' % str(msg), 1) return 0 diff --git a/IncBackups/IncBackupsControl.py b/IncBackups/IncBackupsControl.py index f804b1c1b..56c3a8977 100644 --- a/IncBackups/IncBackupsControl.py +++ b/IncBackups/IncBackupsControl.py @@ -115,7 +115,7 @@ class IncJobs(multi.Thread): final_json = json.dumps({'status': 1, 'error_message': "None", "data": json_data}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg)) #### @@ -163,7 +163,7 @@ class IncJobs(multi.Thread): logging.statusWriter(self.statusPath, result, 1) - except BaseException, msg: + except BaseException as msg: logging.statusWriter(self.statusPath, "%s [88][5009]" % (str(msg)), 1) return 0 @@ -240,7 +240,7 @@ class IncJobs(multi.Thread): else: self.awsFunction('restore', '', self.jobid.snapshotid) - except BaseException, msg: + except BaseException as msg: logging.statusWriter(self.statusPath, "%s [138][5009]" % (str(msg)), 1) return 0 @@ -274,10 +274,10 @@ class IncJobs(multi.Thread): os.remove('/home/cyberpanel/%s' % (self.path.split('/')[-1])) else: os.remove('/home/cyberpanel/%s.sql' % (self.jobid.type.split(':')[1])) - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg)) - except BaseException, msg: + except BaseException as msg: logging.statusWriter(self.statusPath, "%s [160][5009]" % (str(msg)), 1) return 0 @@ -297,7 +297,7 @@ class IncJobs(multi.Thread): else: self.awsFunction('restore', '', self.jobid.snapshotid) - except BaseException, msg: + except BaseException as msg: logging.statusWriter(self.statusPath, "%s [46][5009]" % (str(msg)), 1) return 0 @@ -328,7 +328,7 @@ class IncJobs(multi.Thread): except: pass - except BaseException, msg: + except BaseException as msg: logging.statusWriter(self.statusPath, "%s [46][5009]" % (str(msg)), 1) return 0 @@ -400,7 +400,7 @@ class IncJobs(multi.Thread): logging.statusWriter(self.statusPath, message, 1) logging.statusWriter(self.statusPath, 'Completed', 1) - except BaseException, msg: + except BaseException as msg: logging.statusWriter(self.extraArgs['tempPath'], str(msg), 1) ### Backup functions @@ -520,7 +520,7 @@ class IncJobs(multi.Thread): metaFileXML.append(dnsRecordsXML) - except BaseException, msg: + except BaseException as msg: logging.statusWriter(self.statusPath, '%s. [158:prepMeta]' % (str(msg)), 1) ## Email accounts XML @@ -541,7 +541,7 @@ class IncJobs(multi.Thread): emailRecordsXML.append(emailRecordXML) metaFileXML.append(emailRecordsXML) - except BaseException, msg: + except BaseException as msg: logging.statusWriter(self.statusPath, '%s. [warning:179:prepMeta]' % (str(msg)), 1) ## Email meta generated! @@ -561,7 +561,7 @@ class IncJobs(multi.Thread): metaFile = open(metaPath, 'w') metaFile.write(xmlpretty) metaFile.close() - os.chmod(metaPath, 0640) + os.chmod(metaPath, 0o640) ## meta generated @@ -573,7 +573,7 @@ class IncJobs(multi.Thread): return 1 - except BaseException, msg: + except BaseException as msg: logging.statusWriter(self.statusPath, "%s [207][5009]" % (str(msg)), 1) return 0 @@ -592,7 +592,7 @@ class IncJobs(multi.Thread): logging.statusWriter(self.statusPath, 'Data for %s backed to %s.' % (self.website.domain, self.backupDestinations), 1) return 1 - except BaseException, msg: + except BaseException as msg: logging.statusWriter(self.statusPath, '%s. [IncJobs.backupData.223][5009]' % str(msg), 1) return 0 @@ -617,11 +617,11 @@ class IncJobs(multi.Thread): try: os.remove('/home/cyberpanel/%s.sql' % (items.dbName)) - except BaseException, msg: + except BaseException as msg: logging.statusWriter(self.statusPath, 'Failed to delete database: %s. [IncJobs.backupDatabases.456]' % str(msg), 1) return 1 - except BaseException, msg: + except BaseException as msg: logging.statusWriter(self.statusPath, '%s. [IncJobs.backupDatabases.269][5009]' % str(msg), 1) return 0 @@ -641,7 +641,7 @@ class IncJobs(multi.Thread): logging.statusWriter(self.statusPath, 'Emails for %s backed to %s.' % (self.website.domain, self.backupDestinations), 1) return 1 - except BaseException, msg: + except BaseException as msg: logging.statusWriter(self.statusPath, '%s. [IncJobs.emailBackup.269][5009]' % str(msg), 1) return 0 @@ -661,7 +661,7 @@ class IncJobs(multi.Thread): logging.statusWriter(self.statusPath, 'Meta for %s backed to %s.' % (self.website.domain, self.backupDestinations), 1) return 1 - except BaseException, msg: + except BaseException as msg: logging.statusWriter(self.statusPath, '%s. [IncJobs.metaBackup.269][5009]' % str(msg), 1) return 0 @@ -691,7 +691,7 @@ class IncJobs(multi.Thread): logging.statusWriter(self.statusPath, 'Repo %s initiated for %s.' % (self.backupDestinations, self.website.domain), 1) return 1 - except BaseException, msg: + except BaseException as msg: logging.statusWriter(self.statusPath, '%s. [IncJobs.initiateRepo.47][5009]' % str(msg), 1) return 0 @@ -763,7 +763,7 @@ Subject: %s try: command = 'rm -f %s' % (metaPathNew) ProcessUtilities.executioner(command) - except BaseException, msg: + except BaseException as msg: logging.statusWriter(self.statusPath, 'Failed to delete meta file: %s. [IncJobs.createBackup.591]' % str(msg), 1) diff --git a/IncBackups/IncScheduler.py b/IncBackups/IncScheduler.py index 9319c82d0..6e3a9fc91 100644 --- a/IncBackups/IncScheduler.py +++ b/IncBackups/IncScheduler.py @@ -82,7 +82,7 @@ class IncScheduler(): logging.statusWriter(IncScheduler.logPath, 'Failed backup for %s, error: %s.' % (web.website, result), 1) break - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg)) diff --git a/IncBackups/admin.py b/IncBackups/admin.py index 13be29d96..4c33e0ec3 100644 --- a/IncBackups/admin.py +++ b/IncBackups/admin.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.contrib import admin diff --git a/IncBackups/apps.py b/IncBackups/apps.py index 5511373f4..9605447c5 100644 --- a/IncBackups/apps.py +++ b/IncBackups/apps.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.apps import AppConfig diff --git a/IncBackups/models.py b/IncBackups/models.py index 174db674e..2ed3f4492 100644 --- a/IncBackups/models.py +++ b/IncBackups/models.py @@ -1,4 +1,4 @@ -from __future__ import unicode_literals + from django.db import models from websiteFunctions.models import Websites diff --git a/IncBackups/restoreMeta.py b/IncBackups/restoreMeta.py index 863733514..2f5cc620f 100644 --- a/IncBackups/restoreMeta.py +++ b/IncBackups/restoreMeta.py @@ -49,7 +49,7 @@ class restoreMeta(): virtualHostUtilities.createDomain(masterDomain, domain, phpSelection, path, 0, 0, 0, 'admin', 0) - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + " [startRestore]") return 0 @@ -92,7 +92,7 @@ class restoreMeta(): 'Email created: %s' % ( email)) - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + " [startRestore]") return 0 @@ -148,7 +148,7 @@ class restoreMeta(): except: pass - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + " [startRestore]") def main(): diff --git a/IncBackups/tests.py b/IncBackups/tests.py index 5982e6bcd..f067dcaac 100644 --- a/IncBackups/tests.py +++ b/IncBackups/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.test import TestCase diff --git a/IncBackups/views.py b/IncBackups/views.py index b6a42569d..6923de85d 100644 --- a/IncBackups/views.py +++ b/IncBackups/views.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.shortcuts import render from plogical.acl import ACLManager @@ -48,7 +48,7 @@ def createBackup(request): destinations.append('s3:s3.amazonaws.com/%s' % (items)) return defRenderer(request, 'IncBackups/createBackup.html', {'websiteList': websitesName, 'destinations': destinations}) - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg)) return redirect(loadLoginPage) @@ -61,7 +61,7 @@ def backupDestinations(request): return ACLManager.loadError() return defRenderer(request, 'IncBackups/incrementalDestinations.html', {}) - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg)) return redirect(loadLoginPage) @@ -168,7 +168,7 @@ def addDestination(request): final_json = json.dumps(final_dic) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -235,7 +235,7 @@ def populateCurrentRecords(request): final_json = json.dumps({'status': 1, 'error_message': "None", "data": json_data}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -264,7 +264,7 @@ def removeDestination(request): 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) @@ -337,7 +337,7 @@ def fetchCurrentBackups(request): return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -398,7 +398,7 @@ def submitBackupCreation(request): final_json = json.dumps({'status': 1, 'error_message': "None", 'tempPath': tempPath}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg)) final_dic = {'status': 0, 'metaStatus': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) @@ -456,7 +456,7 @@ def getBackupStatus(request): final_json = json.dumps({'backupStatus': 1, 'error_message': "None", "status": 1, "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.writeToFile(str(msg) + " [backupStatus]") @@ -483,7 +483,7 @@ def deleteBackup(request): 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) @@ -528,7 +528,7 @@ def fetchRestorePoints(request): json_data = json_data + ']' final_json = json.dumps({'status': 1, 'error_message': "None", "data": json_data}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -576,7 +576,7 @@ def restorePoint(request): final_json = json.dumps({'status': 1, 'error_message': "None", 'tempPath': tempPath}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg)) final_dic = {'status': 0, 'metaStatus': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) @@ -607,7 +607,7 @@ def scheduleBackups(request): destinations.append('s3:s3.amazonaws.com/%s' % (items)) return defRenderer(request, 'IncBackups/backupSchedule.html', {'websiteList': websitesName, 'destinations': destinations}) - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg)) return redirect(loadLoginPage) @@ -657,7 +657,7 @@ def submitBackupSchedule(request): return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_json = json.dumps({'status': 0, 'error_message': str(msg)}) return HttpResponse(final_json) @@ -690,7 +690,7 @@ def getCurrentBackupSchedules(request): final_json = json.dumps({'status': 1, 'error_message': "None", "data": json_data}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -713,7 +713,7 @@ def scheduleDelete(request): final_json = json.dumps({'status': 1, 'error_message': "None"}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_json = json.dumps({'status': 0, 'error_message': str(msg)}) return HttpResponse(final_json) @@ -741,6 +741,6 @@ def restoreRemoteBackups(request): destinations.append('s3:s3.amazonaws.com/%s' % (items)) return defRenderer(request, 'IncBackups/restoreRemoteBackups.html', {'websiteList': websitesName, 'destinations': destinations}) - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg)) return redirect(loadLoginPage) \ No newline at end of file diff --git a/WebTerminal/CPWebSocket.py b/WebTerminal/CPWebSocket.py index c5630561b..f3f10003b 100644 --- a/WebTerminal/CPWebSocket.py +++ b/WebTerminal/CPWebSocket.py @@ -82,14 +82,14 @@ class SSHServer(multi.Thread): pass else: return 0 - except BaseException, msg: + except BaseException as msg: time.sleep(0.1) def run(self): try: self.recvData() - except BaseException, msg: - print(str(msg)) + except BaseException as msg: + print((str(msg))) class WebTerminalServer(WebSocket): diff --git a/WebTerminal/admin.py b/WebTerminal/admin.py index 13be29d96..4c33e0ec3 100644 --- a/WebTerminal/admin.py +++ b/WebTerminal/admin.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.contrib import admin diff --git a/WebTerminal/apps.py b/WebTerminal/apps.py index b53c3b4c6..724dc1517 100644 --- a/WebTerminal/apps.py +++ b/WebTerminal/apps.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.apps import AppConfig diff --git a/WebTerminal/models.py b/WebTerminal/models.py index 1dfab7604..4e6a8e76d 100644 --- a/WebTerminal/models.py +++ b/WebTerminal/models.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models diff --git a/WebTerminal/tests.py b/WebTerminal/tests.py index 5982e6bcd..f067dcaac 100644 --- a/WebTerminal/tests.py +++ b/WebTerminal/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.test import TestCase diff --git a/WebTerminal/views.py b/WebTerminal/views.py index a4bab712c..145cfc3bf 100644 --- a/WebTerminal/views.py +++ b/WebTerminal/views.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.shortcuts import render, redirect, HttpResponse from plogical.acl import ACLManager @@ -49,7 +49,7 @@ def terminal(request): newFWRule.save() return render(request, 'WebTerminal/WebTerminal.html', {'verifyPath': verifyPath, 'password': password}) - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg)) return redirect(loadLoginPage) @@ -73,7 +73,7 @@ def restart(request): json_data = json.dumps(data_ret) 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) \ No newline at end of file diff --git a/api/admin.py b/api/admin.py index 13be29d96..4c33e0ec3 100755 --- a/api/admin.py +++ b/api/admin.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.contrib import admin diff --git a/api/apps.py b/api/apps.py index 8f01aa8da..2ab9fa9e6 100755 --- a/api/apps.py +++ b/api/apps.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.apps import AppConfig diff --git a/api/models.py b/api/models.py index 1dfab7604..4e6a8e76d 100755 --- a/api/models.py +++ b/api/models.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models diff --git a/api/tests.py b/api/tests.py index e1391c2a6..a3d7b14d4 100755 --- a/api/tests.py +++ b/api/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.test import TestCase import json diff --git a/api/views.py b/api/views.py index 070e34f47..38c5ac578 100755 --- a/api/views.py +++ b/api/views.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + import json from django.shortcuts import redirect from django.http import HttpResponse @@ -46,7 +46,7 @@ def verifyConn(request): json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'verifyConn': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -107,7 +107,7 @@ def getUserInfo(request): json_data = json.dumps(data_ret) 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) @@ -150,7 +150,7 @@ def changeUserPassAPI(request): json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'changeStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -195,7 +195,7 @@ def changePackageAPI(request): json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'changePackage': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -240,7 +240,7 @@ def deleteWebsite(request): wm = WebsiteManager() return wm.submitWebsiteDeletion(admin.pk, data) - except BaseException, msg: + except BaseException as msg: data_ret = {'websiteDeleteStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -271,7 +271,7 @@ def submitWebsiteStatus(request): wm = WebsiteManager() return wm.submitWebsiteStatus(admin.pk, json.loads(request.body)) - except BaseException, msg: + except BaseException as msg: data_ret = {'websiteStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -295,7 +295,7 @@ def loginAPI(request): else: return HttpResponse("Invalid Credentials.") - except BaseException, msg: + except BaseException as msg: data = {'userID': 0, 'loginStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data) return HttpResponse(json_data) @@ -338,7 +338,7 @@ def fetchSSHkey(request): json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data = {'status' : 0, 'pubKeyStatus': 0,'error_message': str(msg)} json_data = json.dumps(data) return HttpResponse(json_data) @@ -390,7 +390,7 @@ def remoteTransfer(request): json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data = {'transferStatus': 0,'error_message': str(msg)} json_data = json.dumps(data) return HttpResponse(json_data) @@ -440,7 +440,7 @@ def fetchAccountsFromRemoteServer(request): json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data = {'fetchStatus': 0,'error_message': str(msg)} json_data = json.dumps(data) return HttpResponse(json_data) @@ -481,7 +481,7 @@ def FetchRemoteTransferStatus(request): - except BaseException, msg: + except BaseException as msg: data = {'fetchStatus': 0,'error_message': str(msg)} json_data = json.dumps(data) return HttpResponse(json_data) @@ -528,7 +528,7 @@ def cancelRemoteTransfer(request): return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data = {'cancelStatus': 1, 'error_message': str(msg)} json_data = json.dumps(data) return HttpResponse(json_data) @@ -572,7 +572,7 @@ def cyberPanelVersion(request): json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = { "getVersion": 0, 'error_message': str(msg) @@ -590,7 +590,7 @@ def runAWSBackups(request): if os.path.exists(randomFile): s3 = S3Backups(request, None, 'runAWSBackups') s3.start() - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + ' [API.runAWSBackups]') @@ -620,7 +620,7 @@ def submitUserCreation(request): json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'changeStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) \ No newline at end of file diff --git a/backup/admin.py b/backup/admin.py index 1a5033b50..db8eb8864 100755 --- a/backup/admin.py +++ b/backup/admin.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.contrib import admin from .models import DBUsers diff --git a/backup/apps.py b/backup/apps.py index 2b26d2144..5ec5a728d 100755 --- a/backup/apps.py +++ b/backup/apps.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.apps import AppConfig diff --git a/backup/backupManager.py b/backup/backupManager.py index 43642f046..b4b1beae6 100755 --- a/backup/backupManager.py +++ b/backup/backupManager.py @@ -33,7 +33,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): @@ -45,7 +45,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): @@ -73,7 +73,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): @@ -120,7 +120,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) @@ -157,7 +157,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) @@ -240,7 +240,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]") @@ -259,13 +259,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) @@ -291,7 +291,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) @@ -321,7 +321,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) @@ -368,7 +368,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( @@ -381,7 +381,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) @@ -395,7 +395,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): @@ -457,7 +457,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) @@ -492,7 +492,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) @@ -520,7 +520,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) @@ -573,7 +573,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) @@ -600,7 +600,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): @@ -631,7 +631,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) @@ -741,7 +741,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) @@ -802,7 +802,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) @@ -815,7 +815,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): @@ -858,7 +858,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), @@ -930,14 +930,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) @@ -995,13 +995,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) @@ -1045,7 +1045,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) @@ -1075,7 +1075,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) @@ -1122,7 +1122,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) @@ -1168,7 +1168,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) diff --git a/backup/models.py b/backup/models.py index e037c96f7..0d4fdfc55 100755 --- a/backup/models.py +++ b/backup/models.py @@ -1,4 +1,4 @@ -from __future__ import unicode_literals + from django.db import models diff --git a/backup/tests.py b/backup/tests.py index 5982e6bcd..f067dcaac 100755 --- a/backup/tests.py +++ b/backup/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.test import TestCase diff --git a/backup/views.py b/backup/views.py index e237e1094..ef8842283 100755 --- a/backup/views.py +++ b/backup/views.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + # Create your views here. import json @@ -61,7 +61,7 @@ def submitBackupCreation(request): return coreResult - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg)) @@ -337,5 +337,5 @@ def localInitiate(request): if os.path.exists(randomFile): wm = BackupManager() return wm.submitBackupCreation(1, json.loads(request.body)) - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg)) diff --git a/baseTemplate/admin.py b/baseTemplate/admin.py index 13be29d96..4c33e0ec3 100755 --- a/baseTemplate/admin.py +++ b/baseTemplate/admin.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.contrib import admin diff --git a/baseTemplate/apps.py b/baseTemplate/apps.py index 5b384a5e9..f5ce2e6d1 100755 --- a/baseTemplate/apps.py +++ b/baseTemplate/apps.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.apps import AppConfig diff --git a/baseTemplate/models.py b/baseTemplate/models.py index cef15e16d..876f66dcb 100755 --- a/baseTemplate/models.py +++ b/baseTemplate/models.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models diff --git a/baseTemplate/tests.py b/baseTemplate/tests.py index 5982e6bcd..f067dcaac 100755 --- a/baseTemplate/tests.py +++ b/baseTemplate/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.test import TestCase diff --git a/baseTemplate/views.py b/baseTemplate/views.py index 21ee65a91..1e8518247 100755 --- a/baseTemplate/views.py +++ b/baseTemplate/views.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.shortcuts import render,redirect from django.http import HttpResponse @@ -199,7 +199,7 @@ def upgradeStatus(request): return HttpResponse(final_json) - except BaseException,msg: + except BaseException as msg: final_dic = {'upgradeStatus': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -217,6 +217,6 @@ def upgradeVersion(request): vers.build = latest['build'] vers.save() return HttpResponse("Version upgrade OK.") - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) return HttpResponse(str(msg)) \ No newline at end of file diff --git a/cli/cliLogger.py b/cli/cliLogger.py index c5c25a554..24d051087 100755 --- a/cli/cliLogger.py +++ b/cli/cliLogger.py @@ -24,5 +24,5 @@ class cliLogger: return lastFewLines - except subprocess.CalledProcessError,msg: + except subprocess.CalledProcessError as msg: return "File was empty" diff --git a/cli/cyberPanel.py b/cli/cyberPanel.py index f33a7fbca..b3130ab14 100755 --- a/cli/cyberPanel.py +++ b/cli/cyberPanel.py @@ -33,7 +33,7 @@ class cyberPanel: data = json.dumps({'success': operationStatus, 'errorMessage': errorMessage }) - print data + print(data) ## Website Functions @@ -51,7 +51,7 @@ class cyberPanel: else: self.printStatus(0, result[1]) - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) self.printStatus(0, str(msg)) @@ -68,7 +68,7 @@ class cyberPanel: else: self.printStatus(0, result[1]) - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) self.printStatus(0, str(msg)) @@ -77,9 +77,9 @@ class cyberPanel: vhost.deleteVirtualHostConfigurations(domainName) self.printStatus(1, 'None') - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) - print 0 + print(0) def deleteChild(self, childDomain): try: @@ -91,9 +91,9 @@ class cyberPanel: else: self.printStatus(0, result[1]) - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) - print 0 + print(0) def listWebsitesJson(self): try: @@ -122,11 +122,11 @@ class cyberPanel: json_data = json_data + ']' final_json = json.dumps(json_data) - print final_json + print(final_json) - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) - print 0 + print(0) def listWebsitesPretty(self): try: @@ -146,11 +146,11 @@ class cyberPanel: else: state = "Active" table.add_row([items.id, items.domain, ipAddress, items.package.packageName, items.admin.userName, state, items.adminEmail]) - print table + print(table) - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) - print 0 + print(0) def changePHP(self, virtualHostName, phpVersion): try: @@ -167,7 +167,7 @@ class cyberPanel: else: self.printStatus(0, result[1]) - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) self.printStatus(0, str(msg)) @@ -186,7 +186,7 @@ class cyberPanel: self.printStatus(1, 'None') - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) self.printStatus(0, str(msg)) @@ -218,11 +218,11 @@ class cyberPanel: json_data = json_data + ']' final_json = json.dumps(json_data) - print final_json + print(final_json) - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) - print 0 + print(0) def listDNSPretty(self, virtualHostName): try: @@ -237,11 +237,11 @@ class cyberPanel: else: content = items.content table.add_row([items.id, items.type, items.name, content, items.prio, items.ttl]) - print table + print(table) - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) - print 0 + print(0) def listDNSZonesJson(self): try: @@ -264,11 +264,11 @@ class cyberPanel: json_data = json_data + ']' final_json = json.dumps(json_data) - print final_json + print(final_json) - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) - print 0 + print(0) def listDNSZonesPretty(self): try: @@ -280,18 +280,18 @@ class cyberPanel: for items in records: table.add_row([items.id, items.name]) - print table + print(table) - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) - print 0 + print(0) def createDNSZone(self, virtualHostName, owner): try: admin = Administrator.objects.get(userName=owner) DNS.dnsTemplate(virtualHostName, admin) self.printStatus(1, 'None') - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) self.printStatus(0, str(msg)) @@ -300,7 +300,7 @@ class cyberPanel: zone = DNS.getZoneObject(virtualHostName) DNS.createDNSRecord(zone, name, recordType, value, int(priority), int(ttl)) self.printStatus(1, 'None') - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) self.printStatus(0, str(msg)) @@ -308,7 +308,7 @@ class cyberPanel: try: DNS.deleteDNSZone(virtualHostName) self.printStatus(1, 'None') - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) self.printStatus(0, str(msg)) @@ -316,7 +316,7 @@ class cyberPanel: try: DNS.deleteDNSRecord(recordID) self.printStatus(1, 'None') - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) self.printStatus(0, str(msg)) @@ -326,13 +326,13 @@ class cyberPanel: try: backupLogPath = "/usr/local/lscp/logs/backup_log."+time.strftime("%I-%M-%S-%a-%b-%Y") - print 'Backup logs to be generated in %s' % (backupLogPath) + print('Backup logs to be generated in %s' % (backupLogPath)) backupSchedule.createLocalBackup(virtualHostName, backupLogPath) - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) - print 0 + print(0) def restoreBackup(self, fileName): try: @@ -351,19 +351,19 @@ class cyberPanel: data = json.loads(r.text) if data['abort'] == 1 and data['running'] == "Error": - print 'Failed to restore backup, Error message : ' + data['status'] + '\n' + print('Failed to restore backup, Error message : ' + data['status'] + '\n') break elif data['abort'] == 1 and data['running'] == "Completed": - print '\n\n' - print 'Backup restore completed.\n' + print('\n\n') + print('Backup restore completed.\n') break else: - print 'Waiting for restore to complete. Current status: ' + data['status'] + print('Waiting for restore to complete. Current status: ' + data['status']) - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) - print 0 + print(0) ## Packages @@ -380,7 +380,7 @@ class cyberPanel: self.printStatus(1, 'None') - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) self.printStatus(0, str(msg)) @@ -391,7 +391,7 @@ class cyberPanel: delPack.delete() self.printStatus(1, 'None') - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) self.printStatus(0, str(msg)) @@ -422,11 +422,11 @@ class cyberPanel: json_data = json_data + ']' final_json = json.dumps(json_data) - print final_json + print(final_json) - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) - print 0 + print(0) def listPackagesPretty(self): try: @@ -438,11 +438,11 @@ class cyberPanel: for items in records: table.add_row([items.packageName, items.allowedDomains, items.diskSpace, items.bandwidth, items.ftpAccounts, items.dataBases, items.emailAccounts]) - print table + print(table) - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) - print 0 + print(0) ## Database functions @@ -455,7 +455,7 @@ class cyberPanel: self.printStatus(1, 'None') else: self.printStatus(1, result[1]) - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) self.printStatus(0, str(msg)) @@ -468,7 +468,7 @@ class cyberPanel: self.printStatus(1, 'None') else: self.printStatus(1, result[1]) - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) self.printStatus(0, str(msg)) @@ -494,11 +494,11 @@ class cyberPanel: json_data = json_data + ']' final_json = json.dumps(json_data) - print final_json + print(final_json) - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) - print 0 + print(0) def listDatabasesPretty(self, virtualHostName): try: @@ -510,11 +510,11 @@ class cyberPanel: for items in records: table.add_row([items.id, items.dbName, items.dbUser]) - print table + print(table) - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) - print 0 + print(0) ## Email functions @@ -526,7 +526,7 @@ class cyberPanel: self.printStatus(1, 'None') else: self.printStatus(1, result[1]) - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) self.printStatus(0, str(msg)) @@ -538,7 +538,7 @@ class cyberPanel: self.printStatus(1, 'None') else: self.printStatus(1, result[1]) - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) self.printStatus(0, str(msg)) @@ -550,7 +550,7 @@ class cyberPanel: self.printStatus(1, 'None') else: self.printStatus(1, result[1]) - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) self.printStatus(0, str(msg)) @@ -575,11 +575,11 @@ class cyberPanel: json_data = json_data + ']' final_json = json.dumps(json_data) - print final_json + print(final_json) - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) - print 0 + print(0) def listEmailsPretty(self, virtualHostName): try: @@ -591,11 +591,11 @@ class cyberPanel: for items in records: table.add_row([items.email]) - print table + print(table) - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) - print 0 + print(0) ## FTP Functions @@ -612,7 +612,7 @@ class cyberPanel: self.printStatus(1, 'None') else: self.printStatus(1, result[1]) - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) self.printStatus(0, str(msg)) @@ -624,7 +624,7 @@ class cyberPanel: self.printStatus(1, 'None') else: self.printStatus(1, result[1]) - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) self.printStatus(0, str(msg)) @@ -636,7 +636,7 @@ class cyberPanel: self.printStatus(1, 'None') else: self.printStatus(1, result[1]) - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) self.printStatus(0, str(msg)) @@ -662,11 +662,11 @@ class cyberPanel: json_data = json_data + ']' final_json = json.dumps(json_data) - print final_json + print(final_json) - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) - print 0 + print(0) def listFTPPretty(self, virtualHostName): try: @@ -678,11 +678,11 @@ class cyberPanel: for items in records: table.add_row([items.id, items.user, items.dir]) - print table + print(table) - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) - print 0 + print(0) ## FTP Functions @@ -709,7 +709,7 @@ class cyberPanel: self.printStatus(1, 'None') else: self.printStatus(1, result[1]) - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) self.printStatus(0, str(msg)) @@ -733,7 +733,7 @@ class cyberPanel: self.printStatus(1, 'None') else: self.printStatus(1, result[1]) - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) self.printStatus(0, str(msg)) @@ -757,7 +757,7 @@ class cyberPanel: self.printStatus(1, 'None') else: self.printStatus(1, result[1]) - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) self.printStatus(0, str(msg)) @@ -786,7 +786,7 @@ class cyberPanel: ProcessUtilities.restartLitespeed() self.printStatus(1, 'None') - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) self.printStatus(0, str(msg)) @@ -803,23 +803,23 @@ def main(): completeCommandExample = 'cyberpanel createWebsite --package Detault --owner admin --domainName cyberpanel.net --email support@cyberpanel.net --php 5.6' if not args.package: - print "\n\nPlease enter the package name. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the package name. For example:\n\n" + completeCommandExample + "\n\n") return if not args.owner: - print "\n\nPlease enter the owner name. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the owner name. For example:\n\n" + completeCommandExample + "\n\n") return if not args.domainName: - print "\n\nPlease enter the domain name. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the domain name. For example:\n\n" + completeCommandExample + "\n\n") return if not args.email: - print "\n\nPlease enter the email. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the email. For example:\n\n" + completeCommandExample + "\n\n") return if not args.php: - print "\n\nPlease enter the PHP version such as 5.6 for PHP version 5.6. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the PHP version such as 5.6 for PHP version 5.6. For example:\n\n" + completeCommandExample + "\n\n") return if args.ssl: @@ -843,7 +843,7 @@ def main(): completeCommandExample = 'cyberpanel deleteWebsite --domainName cyberpanel.net' if not args.domainName: - print "\n\nPlease enter the domain to delete. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the domain to delete. For example:\n\n" + completeCommandExample + "\n\n") return cyberpanel.deleteWebsite(args.domainName) @@ -853,19 +853,19 @@ def main(): ' --owner admin --php 5.6' if not args.masterDomain: - print "\n\nPlease enter Master domain. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter Master domain. For example:\n\n" + completeCommandExample + "\n\n") return if not args.childDomain: - print "\n\nPlease enter the Child Domain. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the Child Domain. For example:\n\n" + completeCommandExample + "\n\n") return if not args.owner: - print "\n\nPlease enter owner for this domain DNS records. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter owner for this domain DNS records. For example:\n\n" + completeCommandExample + "\n\n") return if not args.php: - print "\n\nPlease enter required PHP version. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter required PHP version. For example:\n\n" + completeCommandExample + "\n\n") return if args.ssl: @@ -889,7 +889,7 @@ def main(): completeCommandExample = 'cyberpanel deleteChild --childDomain cyberpanel.net' if not args.childDomain: - print "\n\nPlease enter the child domain to delete. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the child domain to delete. For example:\n\n" + completeCommandExample + "\n\n") return cyberpanel.deleteChild(args.childDomain) @@ -903,11 +903,11 @@ def main(): completeCommandExample = 'cyberpanel changePHP --domainName cyberpanel.net --php 5.6' if not args.domainName: - print "\n\nPlease enter Domain. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter Domain. For example:\n\n" + completeCommandExample + "\n\n") return if not args.php: - print "\n\nPlease enter required PHP version. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter required PHP version. For example:\n\n" + completeCommandExample + "\n\n") return @@ -917,11 +917,11 @@ def main(): completeCommandExample = 'cyberpanel changePackage --domainName cyberpanel.net --packageName CLI' if not args.domainName: - print "\n\nPlease enter the Domain. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the Domain. For example:\n\n" + completeCommandExample + "\n\n") return if not args.packageName: - print "\n\nPlease enter the package name. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the package name. For example:\n\n" + completeCommandExample + "\n\n") return cyberpanel.changePackage(args.domainName, args.packageName) @@ -933,7 +933,7 @@ def main(): completeCommandExample = 'cyberpanel listDNSJson --domainName cyberpanel.net' if not args.domainName: - print "\n\nPlease enter the domain. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the domain. For example:\n\n" + completeCommandExample + "\n\n") return cyberpanel.listDNSJson(args.domainName) @@ -942,7 +942,7 @@ def main(): completeCommandExample = 'cyberpanel listDNSPretty --domainName cyberpanel.net' if not args.domainName: - print "\n\nPlease enter the domain. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the domain. For example:\n\n" + completeCommandExample + "\n\n") return cyberpanel.listDNSPretty(args.domainName) @@ -954,11 +954,11 @@ def main(): completeCommandExample = 'cyberpanel createDNSZone --owner admin --domainName cyberpanel.net' if not args.domainName: - print "\n\nPlease enter the domain. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the domain. For example:\n\n" + completeCommandExample + "\n\n") return if not args.owner: - print "\n\nPlease enter the owner name. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the owner name. For example:\n\n" + completeCommandExample + "\n\n") return cyberpanel.createDNSZone(args.domainName, args.owner) @@ -966,7 +966,7 @@ def main(): completeCommandExample = 'cyberpanel deleteDNSZone --domainName cyberpanel.net' if not args.domainName: - print "\n\nPlease enter the domain. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the domain. For example:\n\n" + completeCommandExample + "\n\n") return cyberpanel.deleteDNSZone(args.domainName) @@ -975,27 +975,27 @@ def main(): ' --recordType A --value 192.168.100.1 --priority 0 --ttl 3600' if not args.domainName: - print "\n\nPlease enter the domain. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the domain. For example:\n\n" + completeCommandExample + "\n\n") return if not args.name: - print "\n\nPlease enter the record name. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the record name. For example:\n\n" + completeCommandExample + "\n\n") return if not args.recordType: - print "\n\nPlease enter the record type. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the record type. For example:\n\n" + completeCommandExample + "\n\n") return if not args.value: - print "\n\nPlease enter the record value. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the record value. For example:\n\n" + completeCommandExample + "\n\n") return if not args.priority: - print "\n\nPlease enter the priority. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the priority. For example:\n\n" + completeCommandExample + "\n\n") return if not args.ttl: - print "\n\nPlease enter the ttl. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the ttl. For example:\n\n" + completeCommandExample + "\n\n") return cyberpanel.createDNSRecord(args.domainName, args.name, args.recordType, args.value, args.priority, args.ttl) @@ -1003,7 +1003,7 @@ def main(): completeCommandExample = 'cyberpanel deleteDNSRecord --recordID 200' if not args.recordID: - print "\n\nPlease enter the record ID to be deleted, you can find record ID by listing the current DNS records. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the record ID to be deleted, you can find record ID by listing the current DNS records. For example:\n\n" + completeCommandExample + "\n\n") return cyberpanel.deleteDNSRecord(args.recordID) @@ -1015,7 +1015,7 @@ def main(): completeCommandExample = 'cyberpanel createBackup --domainName cyberpanel.net' if not args.domainName: - print "\n\nPlease enter the domain. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the domain. For example:\n\n" + completeCommandExample + "\n\n") return cyberpanel.createBackup(args.domainName) @@ -1024,7 +1024,7 @@ def main(): completeCommandExample = 'cyberpanel restoreBackup --fileName /home/talkshosting.com/backup/backup-talksho-01-30-53-Fri-Jun-2018.tar.gz' if not args.fileName: - print "\n\nPlease enter the file name or complete path to file. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the file name or complete path to file. For example:\n\n" + completeCommandExample + "\n\n") return cyberpanel.restoreBackup(args.fileName) @@ -1037,33 +1037,33 @@ def main(): ' --dataBases 100 --ftpAccounts 100 --allowedDomains 100' if not args.owner: - print "\n\nPlease enter the owner name. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the owner name. For example:\n\n" + completeCommandExample + "\n\n") return if not args.packageName: - print "\n\nPlease enter the package name. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the package name. For example:\n\n" + completeCommandExample + "\n\n") return if not args.diskSpace: - print "\n\nPlease enter value for Disk Space. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter value for Disk Space. For example:\n\n" + completeCommandExample + "\n\n") return if not args.bandwidth: - print "\n\nPlease enter value for Bandwidth. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter value for Bandwidth. For example:\n\n" + completeCommandExample + "\n\n") return if not args.emailAccounts: - print "\n\nPlease enter value for Email accounts. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter value for Email accounts. For example:\n\n" + completeCommandExample + "\n\n") return if not args.dataBases: - print "\n\nPlease enter value for Databases. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter value for Databases. For example:\n\n" + completeCommandExample + "\n\n") return if not args.ftpAccounts: - print "\n\nPlease enter value for Ftp accounts. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter value for Ftp accounts. For example:\n\n" + completeCommandExample + "\n\n") return if not args.allowedDomains: - print "\n\nPlease enter value for Allowed Child Domains. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter value for Allowed Child Domains. For example:\n\n" + completeCommandExample + "\n\n") return @@ -1073,7 +1073,7 @@ def main(): elif args.function == "deletePackage": completeCommandExample = 'cyberpanel deletePackage --packageName CLI' if not args.packageName: - print "\n\nPlease enter the package name. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the package name. For example:\n\n" + completeCommandExample + "\n\n") return cyberpanel.deletePackage(args.packageName) @@ -1090,24 +1090,24 @@ def main(): '--dbUsername cyberpanel --dbPassword cyberpanel' if not args.databaseWebsite: - print "\n\nPlease enter database website. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter database website. For example:\n\n" + completeCommandExample + "\n\n") return if not args.dbName: - print "\n\nPlease enter the database name. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the database name. For example:\n\n" + completeCommandExample + "\n\n") return if not args.dbUsername: - print "\n\nPlease enter the database username. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the database username. For example:\n\n" + completeCommandExample + "\n\n") return if not args.dbPassword: - print "\n\nPlease enter the password for database. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the password for database. For example:\n\n" + completeCommandExample + "\n\n") return cyberpanel.createDatabase(args.dbName, args.dbUsername, args.dbPassword, args.databaseWebsite) elif args.function == "deleteDatabase": completeCommandExample = 'cyberpanel deleteDatabase --dbName cyberpanel' if not args.dbName: - print "\n\nPlease enter the database name. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the database name. For example:\n\n" + completeCommandExample + "\n\n") return cyberpanel.deleteDatabase(args.dbName) @@ -1116,14 +1116,14 @@ def main(): completeCommandExample = 'cyberpanel listDatabasesJson --databaseWebsite cyberpanel.net' if not args.databaseWebsite: - print "\n\nPlease enter database website. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter database website. For example:\n\n" + completeCommandExample + "\n\n") return cyberpanel.listDatabasesJson(args.databaseWebsite) elif args.function == "listDatabasesPretty": completeCommandExample = 'cyberpanel listDatabasesPretty --databaseWebsite cyberpanel.net' if not args.databaseWebsite: - print "\n\nPlease enter database website. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter database website. For example:\n\n" + completeCommandExample + "\n\n") return cyberpanel.listDatabasesPretty(args.databaseWebsite) @@ -1136,14 +1136,14 @@ def main(): '--password cyberpanel' if not args.domainName: - print "\n\nPlease enter Domain name. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter Domain name. For example:\n\n" + completeCommandExample + "\n\n") return if not args.userName: - print "\n\nPlease enter the user name. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the user name. For example:\n\n" + completeCommandExample + "\n\n") return if not args.password: - print "\n\nPlease enter the password for database. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the password for database. For example:\n\n" + completeCommandExample + "\n\n") return cyberpanel.createEmail(args.domainName, args.userName, args.password) @@ -1151,7 +1151,7 @@ def main(): completeCommandExample = 'cyberpanel deleteEmail --email cyberpanel@cyberpanel.net' if not args.email: - print "\n\nPlease enter the email. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the email. For example:\n\n" + completeCommandExample + "\n\n") return cyberpanel.deleteEmail(args.email) @@ -1160,11 +1160,11 @@ def main(): completeCommandExample = 'cyberpanel changeEmailPassword --email cyberpanel@cyberpanel.net --password cyberpanel' if not args.email: - print "\n\nPlease enter email. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter email. For example:\n\n" + completeCommandExample + "\n\n") return if not args.password: - print "\n\nPlease enter the password. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the password. For example:\n\n" + completeCommandExample + "\n\n") return cyberpanel.changeEmailPassword(args.email, args.password) @@ -1172,7 +1172,7 @@ def main(): completeCommandExample = 'cyberpanel listEmailsJson --domainName cyberpanel.net' if not args.domainName: - print "\n\nPlease enter domain name. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter domain name. For example:\n\n" + completeCommandExample + "\n\n") return cyberpanel.listEmailsJson(args.domainName) @@ -1180,7 +1180,7 @@ def main(): completeCommandExample = 'cyberpanel listEmailsPretty --domainName cyberpanel.net' if not args.domainName: - print "\n\nPlease enter domain name. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter domain name. For example:\n\n" + completeCommandExample + "\n\n") return cyberpanel.listEmailsPretty(args.domainName) @@ -1193,18 +1193,18 @@ def main(): '--password cyberpanel --owner admin' if not args.domainName: - print "\n\nPlease enter Domain name. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter Domain name. For example:\n\n" + completeCommandExample + "\n\n") return if not args.userName: - print "\n\nPlease enter the user name. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the user name. For example:\n\n" + completeCommandExample + "\n\n") return if not args.password: - print "\n\nPlease enter the password for database. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the password for database. For example:\n\n" + completeCommandExample + "\n\n") return if not args.owner: - print "\n\nPlease enter the owner name. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the owner name. For example:\n\n" + completeCommandExample + "\n\n") return cyberpanel.createFTPAccount(args.domainName, args.userName, args.password, args.owner) @@ -1212,7 +1212,7 @@ def main(): completeCommandExample = 'cyberpanel deleteFTPAccount --userName cyberpanel' if not args.userName: - print "\n\nPlease enter the user name. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the user name. For example:\n\n" + completeCommandExample + "\n\n") return cyberpanel.deleteFTPAccount(args.userName) @@ -1221,11 +1221,11 @@ def main(): completeCommandExample = 'cyberpanel changeFTPPassword --userName cyberpanel --password cyberpanel' if not args.userName: - print "\n\nPlease enter the user name. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the user name. For example:\n\n" + completeCommandExample + "\n\n") return if not args.password: - print "\n\nPlease enter the password for database. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the password for database. For example:\n\n" + completeCommandExample + "\n\n") return cyberpanel.changeFTPPassword(args.userName, args.password) @@ -1233,7 +1233,7 @@ def main(): completeCommandExample = 'cyberpanel listFTPJson --domainName cyberpanel.net' if not args.domainName: - print "\n\nPlease enter domain name. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter domain name. For example:\n\n" + completeCommandExample + "\n\n") return cyberpanel.listFTPJson(args.domainName) @@ -1241,7 +1241,7 @@ def main(): completeCommandExample = 'cyberpanel listFTPPretty --domainName cyberpanel.net' if not args.domainName: - print "\n\nPlease enter domain name. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter domain name. For example:\n\n" + completeCommandExample + "\n\n") return cyberpanel.listFTPPretty(args.domainName) @@ -1251,7 +1251,7 @@ def main(): completeCommandExample = 'cyberpanel issueSSL --domainName cyberpanel.net' if not args.domainName: - print "\n\nPlease enter Domain name. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter Domain name. For example:\n\n" + completeCommandExample + "\n\n") return cyberpanel.issueSSL(args.domainName) @@ -1259,7 +1259,7 @@ def main(): completeCommandExample = 'cyberpanel hostNameSSL --domainName cyberpanel.net' if not args.domainName: - print "\n\nPlease enter Domain name. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter Domain name. For example:\n\n" + completeCommandExample + "\n\n") return cyberpanel.issueSSLForHostName(args.domainName) @@ -1268,7 +1268,7 @@ def main(): completeCommandExample = 'cyberpanel mailServerSSL --domainName cyberpanel.net' if not args.domainName: - print "\n\nPlease enter Domain name. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter Domain name. For example:\n\n" + completeCommandExample + "\n\n") return cyberpanel.issueSSLForMailServer(args.domainName) @@ -1277,7 +1277,7 @@ def main(): completeCommandExample = 'cyberpanel issueSelfSignedSSL --domainName cyberpanel.net' if not args.domainName: - print "\n\nPlease enter Domain name. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter Domain name. For example:\n\n" + completeCommandExample + "\n\n") return cyberpanel.issueSelfSignedSSL(args.domainName) diff --git a/cloudAPI/admin.py b/cloudAPI/admin.py index 13be29d96..4c33e0ec3 100755 --- a/cloudAPI/admin.py +++ b/cloudAPI/admin.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.contrib import admin diff --git a/cloudAPI/apps.py b/cloudAPI/apps.py index 504e7eea9..ede1e3740 100755 --- a/cloudAPI/apps.py +++ b/cloudAPI/apps.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.apps import AppConfig diff --git a/cloudAPI/cloudManager.py b/cloudAPI/cloudManager.py index 6f6b5cfb1..d53190453 100755 --- a/cloudAPI/cloudManager.py +++ b/cloudAPI/cloudManager.py @@ -40,14 +40,14 @@ class CloudManager: else: return 0, self.ajaxPre(0, 'Invalid login information.') - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchWebsites(self): try: wm = WebsiteManager() return wm.getFurtherAccounts(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def submitWebsiteDeletion(self, request): @@ -55,7 +55,7 @@ class CloudManager: request.session['userID'] = self.admin.pk wm = WebsiteManager() return wm.submitWebsiteDeletion(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def submitWebsiteCreation(self): @@ -82,25 +82,25 @@ class CloudManager: token=token ) newAdmin.save() - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg)) admin = Administrator.objects.get(userName=UserAccountName) admin.token = token admin.password = password admin.save() - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg)) wm = WebsiteManager() return wm.submitWebsiteCreation(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchWebsiteDataJSON(self): try: wm = WebsiteManager() return wm.fetchWebsiteDataJSON(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchWebsiteData(self): @@ -160,70 +160,70 @@ class CloudManager: final_json = json.dumps(Data) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchModifyData(self): try: wm = WebsiteManager() return wm.submitWebsiteModify(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def saveModifications(self): try: wm = WebsiteManager() return wm.saveWebsiteChanges(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def submitDBCreation(self): try: dm = DatabaseManager() return dm.submitDBCreation(self.admin.pk, self.data, 1) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchDatabases(self): try: dm = DatabaseManager() return dm.fetchDatabases(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def submitDatabaseDeletion(self): try: dm = DatabaseManager() return dm.submitDatabaseDeletion(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def changePassword(self): try: dm = DatabaseManager() return dm.changePassword(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def getCurrentRecordsForDomain(self): try: dm = DNSManager() return dm.getCurrentRecordsForDomain(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def deleteDNSRecord(self): try: dm = DNSManager() return dm.deleteDNSRecord(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def addDNSRecord(self): try: dm = DNSManager() return dm.addDNSRecord(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def submitEmailCreation(self, request): @@ -231,7 +231,7 @@ class CloudManager: request.session['userID'] = self.admin.pk msm = MailServerManager(request) return msm.submitEmailCreation() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def getEmailsForDomain(self, request): @@ -239,7 +239,7 @@ class CloudManager: request.session['userID'] = self.admin.pk msm = MailServerManager(request) return msm.getEmailsForDomain() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def submitEmailDeletion(self, request): @@ -247,7 +247,7 @@ class CloudManager: request.session['userID'] = self.admin.pk msm = MailServerManager(request) return msm.submitEmailDeletion() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def submitPasswordChange(self, request): @@ -255,7 +255,7 @@ class CloudManager: request.session['userID'] = self.admin.pk msm = MailServerManager(request) return msm.submitPasswordChange() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchCurrentForwardings(self, request): @@ -263,7 +263,7 @@ class CloudManager: request.session['userID'] = self.admin.pk msm = MailServerManager(request) return msm.fetchCurrentForwardings() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def submitForwardDeletion(self, request): @@ -271,7 +271,7 @@ class CloudManager: request.session['userID'] = self.admin.pk msm = MailServerManager(request) return msm.submitForwardDeletion() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def submitEmailForwardingCreation(self, request): @@ -279,7 +279,7 @@ class CloudManager: request.session['userID'] = self.admin.pk msm = MailServerManager(request) return msm.submitEmailForwardingCreation() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchDKIMKeys(self, request): @@ -287,7 +287,7 @@ class CloudManager: request.session['userID'] = self.admin.pk msm = MailServerManager(request) return msm.fetchDKIMKeys() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def generateDKIMKeys(self, request): @@ -295,7 +295,7 @@ class CloudManager: request.session['userID'] = self.admin.pk msm = MailServerManager(request) return msm.generateDKIMKeys() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def submitFTPCreation(self, request): @@ -303,7 +303,7 @@ class CloudManager: request.session['userID'] = self.admin.pk fm = FTPManager(request) return fm.submitFTPCreation() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def getAllFTPAccounts(self, request): @@ -311,7 +311,7 @@ class CloudManager: request.session['userID'] = self.admin.pk fm = FTPManager(request) return fm.getAllFTPAccounts() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def submitFTPDelete(self, request): @@ -319,7 +319,7 @@ class CloudManager: request.session['userID'] = self.admin.pk fm = FTPManager(request) return fm.submitFTPDelete() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def changeFTPPassword(self, request): @@ -327,14 +327,14 @@ class CloudManager: request.session['userID'] = self.admin.pk fm = FTPManager(request) return fm.changePassword() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def issueSSL(self, request): try: request.session['userID'] = self.admin.pk return issueSSL(request) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def statusFunc(self): @@ -365,7 +365,7 @@ class CloudManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'abort': 0, 'installationProgress': "0", 'errorMessage': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -374,35 +374,35 @@ class CloudManager: try: wm = WebsiteManager() return wm.submitDomainCreation(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchDomains(self): try: wm = WebsiteManager() return wm.fetchDomains(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def submitDomainDeletion(self): try: wm = WebsiteManager() return wm.submitDomainDeletion(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def changeOpenBasedir(self): try: wm = WebsiteManager() return wm.changeOpenBasedir(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def changePHP(self): try: wm = WebsiteManager() return wm.changePHP(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def backupStatusFunc(self): @@ -410,7 +410,7 @@ class CloudManager: bm = BackupManager() return bm.backupStatus(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'abort': 0, 'installationProgress': "0", 'errorMessage': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -419,21 +419,21 @@ class CloudManager: try: bm = BackupManager() return bm.submitBackupCreation(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def getCurrentBackups(self): try: bm = BackupManager() return bm.getCurrentBackups(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def deleteBackup(self): try: bm = BackupManager() return bm.deleteBackup(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchACLs(self): @@ -466,14 +466,14 @@ class CloudManager: final_json = json.dumps({'status': 1, 'error_message': "None", "data": json_data}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def submitUserCreation(self, request): try: request.session['userID'] = self.admin.pk return um.submitUserCreation(request) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchUsers(self): @@ -505,21 +505,21 @@ class CloudManager: final_json = json.dumps({'status': 1, 'error_message': "None", "data": json_data}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def submitUserDeletion(self, request): try: request.session['userID'] = self.admin.pk return um.submitUserDeletion(request) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def saveModificationsUser(self, request): try: request.session['userID'] = self.admin.pk return um.saveModifications(request) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def userWithResellerPriv(self): @@ -544,28 +544,28 @@ class CloudManager: json_data = json_data + ']' final_json = json.dumps({'status': 1, 'error_message': "None", "data": json_data}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def saveResellerChanges(self, request): try: request.session['userID'] = self.admin.pk return um.saveResellerChanges(request) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def changeACLFunc(self, request): try: request.session['userID'] = self.admin.pk return um.changeACLFunc(request) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def createACLFunc(self, request): try: request.session['userID'] = self.admin.pk return um.createACLFunc(request) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def findAllACLs(self, request): @@ -593,28 +593,28 @@ class CloudManager: json_data = json_data + ']' final_json = json.dumps({'status': 1, 'error_message': "None", "data": json_data}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def deleteACLFunc(self, request): try: request.session['userID'] = self.admin.pk return um.deleteACLFunc(request) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchACLDetails(self, request): try: request.session['userID'] = self.admin.pk return um.fetchACLDetails(request) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def submitACLModifications(self, request): try: request.session['userID'] = self.admin.pk return um.submitACLModifications(request) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def submitPackage(self, request): @@ -622,7 +622,7 @@ class CloudManager: request.session['userID'] = self.admin.pk pm = PackagesManager(request) return pm.submitPackage() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchPackages(self, request): @@ -658,7 +658,7 @@ class CloudManager: json_data = json_data + ']' final_json = json.dumps({'status': 1, 'error_message': "None", "data": json_data}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def submitPackageDelete(self, request): @@ -666,7 +666,7 @@ class CloudManager: request.session['userID'] = self.admin.pk pm = PackagesManager(request) return pm.submitDelete() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def submitPackageModify(self, request): @@ -674,21 +674,21 @@ class CloudManager: request.session['userID'] = self.admin.pk pm = PackagesManager(request) return pm.saveChanges() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def getDataFromLogFile(self, request): try: wm = WebsiteManager() return wm.getDataFromLogFile(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchErrorLogs(self, request): try: wm = WebsiteManager() return wm.fetchErrorLogs(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def submitApplicationInstall(self, request): @@ -703,7 +703,7 @@ class CloudManager: elif self.data['selectedApplication'] == 'Joomla': return wm.installJoomla(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def obtainServer(self, request): @@ -712,63 +712,63 @@ class CloudManager: data_ret = {'status': 1, 'serverStatus': ProcessUtilities.decideServer()} json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def getSSHConfigs(self): try: fm = FirewallManager() return fm.getSSHConfigs(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def saveSSHConfigs(self): try: fm = FirewallManager() return fm.saveSSHConfigs(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def deleteSSHKey(self): try: fm = FirewallManager() return fm.deleteSSHKey(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def addSSHKey(self): try: fm = FirewallManager() return fm.addSSHKey(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def getCurrentRules(self): try: fm = FirewallManager() return fm.getCurrentRules(self.admin.pk) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def addRule(self): try: fm = FirewallManager() return fm.addRule(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def deleteRule(self): try: fm = FirewallManager() return fm.deleteRule(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def getLogsFromFile(self, request): try: request.session['userID'] = self.admin.pk return getLogsFromFile(request) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def serverSSL(self, request): @@ -778,7 +778,7 @@ class CloudManager: return obtainHostNameSSL(request) else: return obtainMailServerSSL(request) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def setupManager(self, request): @@ -796,7 +796,7 @@ class CloudManager: proc = httpProc(request, None) return proc.ajax(1, None, data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchManagerTokens(self, request): @@ -805,7 +805,7 @@ class CloudManager: ham = HAManager(request, self.data, 'fetchManagerTokens') return ham.fetchManagerTokens() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def addWorker(self, request): @@ -814,7 +814,7 @@ class CloudManager: ham = HAManager(request, self.data, 'fetchManagerTokens') return ham.addWorker() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchSSHKey(self, request): @@ -830,14 +830,14 @@ class CloudManager: } json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def putSSHkeyFunc(self, request): try: fm = FirewallManager(request) return fm.addSSHKey(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def leaveSwarm(self, request): @@ -845,7 +845,7 @@ class CloudManager: request.session['userID'] = self.admin.pk ham = HAManager(request, self.data, 'leaveSwarm') return ham.leaveSwarm() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def setUpDataNode(self, request): @@ -853,7 +853,7 @@ class CloudManager: request.session['userID'] = self.admin.pk ham = HAManager(request, self.data, 'setUpDataNode') return ham.setUpDataNode() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def submitEditCluster(self, request): @@ -861,7 +861,7 @@ class CloudManager: request.session['userID'] = self.admin.pk ham = HAManager(request, self.data, 'submitEditCluster') return ham.submitEditCluster() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def connectAccount(self, request): @@ -869,7 +869,7 @@ class CloudManager: request.session['userID'] = self.admin.pk s3 = S3Backups(request, self.data, 'connectAccount') return s3.connectAccount() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchBuckets(self, request): @@ -877,7 +877,7 @@ class CloudManager: request.session['userID'] = self.admin.pk s3 = S3Backups(request, self.data, 'fetchBuckets') return s3.fetchBuckets() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def createPlan(self, request): @@ -885,7 +885,7 @@ class CloudManager: request.session['userID'] = self.admin.pk s3 = S3Backups(request, self.data, 'createPlan') return s3.createPlan() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchBackupPlans(self, request): @@ -893,7 +893,7 @@ class CloudManager: request.session['userID'] = self.admin.pk s3 = S3Backups(request, self.data, 'fetchBackupPlans') return s3.fetchBackupPlans() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def deletePlan(self, request): @@ -901,7 +901,7 @@ class CloudManager: request.session['userID'] = self.admin.pk s3 = S3Backups(request, self.data, 'deletePlan') return s3.deletePlan() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchWebsitesInPlan(self, request): @@ -909,7 +909,7 @@ class CloudManager: request.session['userID'] = self.admin.pk s3 = S3Backups(request, self.data, 'fetchWebsitesInPlan') return s3.fetchWebsitesInPlan() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def deleteDomainFromPlan(self, request): @@ -917,7 +917,7 @@ class CloudManager: request.session['userID'] = self.admin.pk s3 = S3Backups(request, self.data, 'deleteDomainFromPlan') return s3.deleteDomainFromPlan() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def savePlanChanges(self, request): @@ -925,7 +925,7 @@ class CloudManager: request.session['userID'] = self.admin.pk s3 = S3Backups(request, self.data, 'savePlanChanges') return s3.savePlanChanges() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchBackupLogs(self, request): @@ -933,7 +933,7 @@ class CloudManager: request.session['userID'] = self.admin.pk s3 = S3Backups(request, self.data, 'fetchBackupLogs') return s3.fetchBackupLogs() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def forceRunAWSBackup(self, request): @@ -942,14 +942,14 @@ class CloudManager: s3 = S3Backups(request, self.data, 'forceRunAWSBackup') s3.start() return self.ajaxPre(1, None) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def systemStatus(self, request): try: return topProcessesStatus(request) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) @@ -957,7 +957,7 @@ class CloudManager: try: request.session['userID'] = self.admin.pk return killProcess(request) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) @@ -966,7 +966,7 @@ class CloudManager: request.session['userID'] = self.admin.pk s3 = S3Backups(request, self.data, 'connectAccountDO') return s3.connectAccountDO() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchBucketsDO(self, request): @@ -974,7 +974,7 @@ class CloudManager: request.session['userID'] = self.admin.pk s3 = S3Backups(request, self.data, 'fetchBucketsDO') return s3.fetchBucketsDO() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) @@ -983,7 +983,7 @@ class CloudManager: request.session['userID'] = self.admin.pk s3 = S3Backups(request, self.data, 'createPlanDO') return s3.createPlanDO() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchBackupPlansDO(self, request): @@ -991,7 +991,7 @@ class CloudManager: request.session['userID'] = self.admin.pk s3 = S3Backups(request, self.data, 'fetchBackupPlansDO') return s3.fetchBackupPlansDO() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def deletePlanDO(self, request): @@ -999,7 +999,7 @@ class CloudManager: request.session['userID'] = self.admin.pk s3 = S3Backups(request, self.data, 'deletePlanDO') return s3.deletePlanDO() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchWebsitesInPlanDO(self, request): @@ -1007,7 +1007,7 @@ class CloudManager: request.session['userID'] = self.admin.pk s3 = S3Backups(request, self.data, 'fetchWebsitesInPlanDO') return s3.fetchWebsitesInPlanDO() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchBackupLogsDO(self, request): @@ -1015,7 +1015,7 @@ class CloudManager: request.session['userID'] = self.admin.pk s3 = S3Backups(request, self.data, 'fetchBackupLogsDO') return s3.fetchBackupLogsDO() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def deleteDomainFromPlanDO(self, request): @@ -1023,7 +1023,7 @@ class CloudManager: request.session['userID'] = self.admin.pk s3 = S3Backups(request, self.data, 'deleteDomainFromPlanDO') return s3.deleteDomainFromPlanDO() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def savePlanChangesDO(self, request): @@ -1031,7 +1031,7 @@ class CloudManager: request.session['userID'] = self.admin.pk s3 = S3Backups(request, self.data, 'savePlanChangesDO') return s3.savePlanChangesDO() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def forceRunAWSBackupDO(self, request): @@ -1040,7 +1040,7 @@ class CloudManager: s3 = S3Backups(request, self.data, 'forceRunAWSBackupDO') s3.start() return self.ajaxPre(1, None) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def showStatus(self, request): @@ -1055,7 +1055,7 @@ class CloudManager: finalData = json.dumps(finalData) return HttpResponse(finalData) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchRam(self, request): @@ -1088,7 +1088,7 @@ class CloudManager: finalData = json.dumps(finalData) return HttpResponse(finalData) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def applyMySQLChanges(self, request): @@ -1106,7 +1106,7 @@ class CloudManager: else: return self.ajaxPre(1, None) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def restartMySQL(self, request): @@ -1121,7 +1121,7 @@ class CloudManager: finalData = json.dumps(finalData) return HttpResponse(finalData) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchDatabasesMYSQL(self, request): @@ -1136,7 +1136,7 @@ class CloudManager: finalData = json.dumps(finalData) return HttpResponse(finalData) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchTables(self, request): @@ -1151,7 +1151,7 @@ class CloudManager: finalData = json.dumps(finalData) return HttpResponse(finalData) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def deleteTable(self, request): @@ -1166,7 +1166,7 @@ class CloudManager: finalData = json.dumps(finalData) return HttpResponse(finalData) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchTableData(self, request): @@ -1181,7 +1181,7 @@ class CloudManager: finalData = json.dumps(finalData) return HttpResponse(finalData) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchStructure(self, request): @@ -1196,7 +1196,7 @@ class CloudManager: finalData = json.dumps(finalData) return HttpResponse(finalData) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def addMINIONode(self, request): @@ -1204,7 +1204,7 @@ class CloudManager: request.session['userID'] = self.admin.pk s3 = S3Backups(request, self.data, 'addMINIONode') return s3.addMINIONode() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchMINIONodes(self, request): @@ -1212,7 +1212,7 @@ class CloudManager: request.session['userID'] = self.admin.pk s3 = S3Backups(request, self.data, 'fetchMINIONodes') return s3.fetchMINIONodes() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def deleteMINIONode(self, request): @@ -1220,7 +1220,7 @@ class CloudManager: request.session['userID'] = self.admin.pk s3 = S3Backups(request, self.data, 'deleteMINIONode') return s3.deleteMINIONode() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def createPlanMINIO(self, request): @@ -1228,7 +1228,7 @@ class CloudManager: request.session['userID'] = self.admin.pk s3 = S3Backups(request, self.data, 'createPlanMINIO') return s3.createPlanMINIO() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchBackupPlansMINIO(self, request): @@ -1236,7 +1236,7 @@ class CloudManager: request.session['userID'] = self.admin.pk s3 = S3Backups(request, self.data, 'fetchBackupPlansMINIO') return s3.fetchBackupPlansMINIO() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) @@ -1245,7 +1245,7 @@ class CloudManager: request.session['userID'] = self.admin.pk s3 = S3Backups(request, self.data, 'deletePlanMINIO') return s3.deletePlanMINIO() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def savePlanChangesMINIO(self, request): @@ -1253,7 +1253,7 @@ class CloudManager: request.session['userID'] = self.admin.pk s3 = S3Backups(request, self.data, 'savePlanChangesMINIO') return s3.savePlanChangesMINIO() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def forceRunAWSBackupMINIO(self, request): @@ -1262,7 +1262,7 @@ class CloudManager: s3 = S3Backups(request, self.data, 'forceRunAWSBackupMINIO') s3.start() return self.ajaxPre(1, None) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchWebsitesInPlanMINIO(self, request): @@ -1270,7 +1270,7 @@ class CloudManager: request.session['userID'] = self.admin.pk s3 = S3Backups(request, self.data, 'fetchWebsitesInPlanMINIO') return s3.fetchWebsitesInPlanMINIO() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchBackupLogsMINIO(self, request): @@ -1278,7 +1278,7 @@ class CloudManager: request.session['userID'] = self.admin.pk s3 = S3Backups(request, self.data, 'fetchBackupLogsMINIO') return s3.fetchBackupLogsMINIO() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def deleteDomainFromPlanMINIO(self, request): @@ -1286,7 +1286,7 @@ class CloudManager: request.session['userID'] = self.admin.pk s3 = S3Backups(request, self.data, 'deleteDomainFromPlanMINIO') return s3.deleteDomainFromPlanMINIO() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def submitWebsiteStatus(self, request): @@ -1294,7 +1294,7 @@ class CloudManager: request.session['userID'] = self.admin.pk wm = WebsiteManager() return wm.submitWebsiteStatus(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def submitChangePHP(self, request): @@ -1302,7 +1302,7 @@ class CloudManager: request.session['userID'] = self.admin.pk wm = WebsiteManager() return wm.changePHP(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def getSwitchStatus(self, request): @@ -1310,7 +1310,7 @@ class CloudManager: request.session['userID'] = self.admin.pk wm = WebsiteManager() return wm.getSwitchStatus(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) @@ -1319,7 +1319,7 @@ class CloudManager: request.session['userID'] = self.admin.pk wm = WebsiteManager() return wm.switchServer(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def tuneSettings(self, request): @@ -1327,42 +1327,42 @@ class CloudManager: request.session['userID'] = self.admin.pk wm = WebsiteManager() return wm.tuneSettings(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def getCurrentPHPConfig(self, request): try: request.session['userID'] = self.admin.pk return PHPManager.getCurrentPHPConfig(self.data['phpSelection']) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def savePHPConfigBasic(self, request): try: request.session['userID'] = self.admin.pk return PHPManager.savePHPConfigBasic(self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchPHPSettingsAdvance(self, request): try: request.session['userID'] = self.admin.pk return PHPManager.fetchPHPSettingsAdvance(self.data['phpSelection']) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def savePHPConfigAdvance(self, request): try: request.session['userID'] = self.admin.pk return PHPManager.savePHPConfigAdvance(self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchPHPExtensions(self, request): try: request.session['userID'] = self.admin.pk return PHPManager.fetchPHPExtensions(self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def submitExtensionRequest(self, request): @@ -1370,14 +1370,14 @@ class CloudManager: request.session['userID'] = self.admin.pk submitExtensionRequest(request) return self.ajaxPre(1, 'None') - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def getRequestStatus(self, request): try: request.session['userID'] = self.admin.pk return getRequestStatusApache(request) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def getContainerizationStatus(self, request): @@ -1394,7 +1394,7 @@ class CloudManager: finalData = json.dumps(finalData) return HttpResponse(finalData) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def submitContainerInstall(self, request): @@ -1414,33 +1414,33 @@ class CloudManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def switchTOLSWSStatus(self, request): try: request.session['userID'] = self.admin.pk return switchTOLSWSStatus(request) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchWebsiteLimits(self, request): try: request.session['userID'] = self.admin.pk return fetchWebsiteLimits(request) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def saveWebsiteLimits(self, request): try: request.session['userID'] = self.admin.pk return saveWebsiteLimits(request) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def getUsageData(self, request): try: request.session['userID'] = self.admin.pk return getUsageData(request) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) \ No newline at end of file diff --git a/cloudAPI/models.py b/cloudAPI/models.py index 1dfab7604..4e6a8e76d 100755 --- a/cloudAPI/models.py +++ b/cloudAPI/models.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models diff --git a/cloudAPI/tests.py b/cloudAPI/tests.py index 5982e6bcd..f067dcaac 100755 --- a/cloudAPI/tests.py +++ b/cloudAPI/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.test import TestCase diff --git a/cloudAPI/views.py b/cloudAPI/views.py index 40df5120d..cec667668 100755 --- a/cloudAPI/views.py +++ b/cloudAPI/views.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from cloudManager import CloudManager import json @@ -307,6 +307,6 @@ def router(request): else: return cm.ajaxPre(0, 'This function is not available in your version of CyberPanel.') - except BaseException, msg: + except BaseException as msg: cm = CloudManager(None) return cm.ajaxPre(0, str(msg)) diff --git a/containerization/admin.py b/containerization/admin.py index 13be29d96..4c33e0ec3 100755 --- a/containerization/admin.py +++ b/containerization/admin.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.contrib import admin diff --git a/containerization/apps.py b/containerization/apps.py index 466ee5897..309e75399 100755 --- a/containerization/apps.py +++ b/containerization/apps.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.apps import AppConfig diff --git a/containerization/container.py b/containerization/container.py index 63bbc2242..3169d9e28 100755 --- a/containerization/container.py +++ b/containerization/container.py @@ -18,12 +18,12 @@ class Container: length = len(Container.users) for items in Container.users: if (counter + 1) == length: - print items + ' ' + Container.packages[counter] + print(items + ' ' + Container.packages[counter]) else: - print items + ' ' + Container.packages[counter] + ' ' + print(items + ' ' + Container.packages[counter] + ' ') counter = counter + 1 - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) @staticmethod @@ -33,12 +33,12 @@ class Container: length = len(Container.users) for items in Container.packages: if (counter + 1) == length: - print items + print(items) else: - print items + '\n' + print(items + '\n') counter = counter + 1 - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) @staticmethod @@ -47,10 +47,10 @@ class Container: counter = 0 for items in Container.users: if items == user: - print Container.packages[counter] + print(Container.packages[counter]) return counter = counter + 1 - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) @staticmethod @@ -59,10 +59,10 @@ class Container: counter = 0 for items in Container.packages: if items == package: - print Container.users[counter] + print(Container.users[counter]) return counter = counter + 1 - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) @staticmethod @@ -88,7 +88,7 @@ class Container: logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, "Packages successfully installed.[200]\n", 1) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, str(msg) + ' [404].', 1) def main(): diff --git a/containerization/containerManager.py b/containerization/containerManager.py index d419b9435..a79cbac74 100755 --- a/containerization/containerManager.py +++ b/containerization/containerManager.py @@ -43,7 +43,7 @@ class ContainerManager(multi.Thread): self.addTrafficController() elif self.function == 'removeLimits': self.removeLimits() - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + ' [ContainerManager.run]') @staticmethod @@ -78,7 +78,7 @@ class ContainerManager(multi.Thread): ioConf = ioConf.replace('{net_cls}', str(net_cls)) return ioConf - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) return 0 @@ -128,7 +128,7 @@ class ContainerManager(multi.Thread): execPath = execPath + " --function submitContainerInstall" ProcessUtilities.outputExecutioner(execPath) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, str(msg) + ' [404].', 1) def restartServices(self): diff --git a/containerization/models.py b/containerization/models.py index ae33028e0..2d6cc3aef 100755 --- a/containerization/models.py +++ b/containerization/models.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models from websiteFunctions.models import Websites diff --git a/containerization/tests.py b/containerization/tests.py index 5982e6bcd..f067dcaac 100755 --- a/containerization/tests.py +++ b/containerization/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.test import TestCase diff --git a/containerization/views.py b/containerization/views.py index a82414868..817cfdd83 100755 --- a/containerization/views.py +++ b/containerization/views.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.shortcuts import HttpResponse, redirect from loginSystem.views import loadLoginPage @@ -42,7 +42,7 @@ def submitContainerInstall(request): json_data = json.dumps(data_ret) 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) @@ -117,7 +117,7 @@ def fetchWebsiteLimits(request): json_data = json.dumps(finalData) 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) @@ -264,7 +264,7 @@ def saveWebsiteLimits(request): json_data = json.dumps(finalData) 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) @@ -345,7 +345,7 @@ def getUsageData(request): final_json = json.dumps(finalData) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'error_message': str(msg), 'cpu': 0, 'memory':0} json_data = json.dumps(data_ret) return HttpResponse(json_data) \ No newline at end of file diff --git a/databases/admin.py b/databases/admin.py index 742c34400..8585adea5 100755 --- a/databases/admin.py +++ b/databases/admin.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.contrib import admin import models diff --git a/databases/apps.py b/databases/apps.py index d0b728055..1e9ba9649 100755 --- a/databases/apps.py +++ b/databases/apps.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.apps import AppConfig diff --git a/databases/databaseManager.py b/databases/databaseManager.py index 721129317..525011f63 100755 --- a/databases/databaseManager.py +++ b/databases/databaseManager.py @@ -22,13 +22,13 @@ class DatabaseManager: def loadDatabaseHome(self, request = None, userID = None): try: return render(request, 'databases/index.html') - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def phpMyAdmin(self, request = None, userID = None): try: return render(request, 'databases/phpMyAdmin.html') - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def createDatabase(self, request = None, userID = None): @@ -40,7 +40,7 @@ class DatabaseManager: websitesName = ACLManager.findAllSites(currentACL, userID) return render(request, 'databases/createDatabase.html', {'websitesList': websitesName}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def submitDBCreation(self, userID = None, data = None, rAPI = None): @@ -76,7 +76,7 @@ class DatabaseManager: data_ret = {'status': 0, 'createDBStatus': 0, 'error_message': result[1]} json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'createDBStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -91,7 +91,7 @@ class DatabaseManager: websitesName = ACLManager.findAllSites(currentACL, userID) return render(request, 'databases/deleteDatabase.html', {'websitesList': websitesName}) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) return HttpResponse(str(msg)) @@ -132,7 +132,7 @@ class DatabaseManager: 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: logging.CyberCPLogFileWriter.writeToFile(str(msg)) final_json = json.dumps({'status': 0, 'fetchStatus': 0, 'error_message': str(msg)}) return HttpResponse(final_json) @@ -163,7 +163,7 @@ class DatabaseManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'deleteStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -177,7 +177,7 @@ class DatabaseManager: websitesName = ACLManager.findAllSites(currentACL, userID) return render(request, 'databases/listDataBases.html', {'websiteList': websitesName}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def changePassword(self, userID = None, data = None): @@ -210,7 +210,7 @@ class DatabaseManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'changePasswordStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -238,10 +238,10 @@ class DatabaseManager: for db in webs.databases_set.all(): mysqlUtilities.allowGlobalUserAccess(admin.userName, db.dbName) - print "1," + finalUserPassword + print("1," + finalUserPassword) - except BaseException, msg: - print "0," + str(msg) + except BaseException as msg: + print("0," + str(msg)) def main(): diff --git a/databases/models.py b/databases/models.py index 73fc909c4..ec573f38a 100755 --- a/databases/models.py +++ b/databases/models.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models from websiteFunctions.models import Websites diff --git a/databases/tests.py b/databases/tests.py index 0a0cddb81..70b95a818 100755 --- a/databases/tests.py +++ b/databases/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.test import TestCase import json diff --git a/databases/views.py b/databases/views.py index 853198776..1a558a79b 100755 --- a/databases/views.py +++ b/databases/views.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.shortcuts import redirect, HttpResponse from loginSystem.views import loadLoginPage @@ -151,7 +151,7 @@ def setupPHPMYAdminSession(request): return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'createDBStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) diff --git a/dns/admin.py b/dns/admin.py index 9962ad720..5cf394083 100755 --- a/dns/admin.py +++ b/dns/admin.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + import models from django.contrib import admin diff --git a/dns/apps.py b/dns/apps.py index 7974ec10b..84a08ccdd 100755 --- a/dns/apps.py +++ b/dns/apps.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.apps import AppConfig diff --git a/dns/dnsManager.py b/dns/dnsManager.py index 180a705ca..a372eb621 100755 --- a/dns/dnsManager.py +++ b/dns/dnsManager.py @@ -24,7 +24,7 @@ class DNSManager: try: admin = Administrator.objects.get(pk=userID) return render(request, 'dns/index.html', {"type": admin.type}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def createNameserver(self, request = None, userID = None): @@ -40,7 +40,7 @@ class DNSManager: else: return render(request, "dns/createNameServer.html", {"status": 0}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def NSCreation(self, userID = None, data = None): @@ -94,7 +94,7 @@ class DNSManager: return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'NSCreation': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -109,7 +109,7 @@ class DNSManager: return render(request, 'dns/createDNSZone.html', {"status": 1}) else: return render(request, 'dns/createDNSZone.html', {"status": 0}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def zoneCreation(self, userID = None, data = None): @@ -142,7 +142,7 @@ class DNSManager: final_json = json.dumps(final_dic) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'zoneCreation': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -161,7 +161,7 @@ class DNSManager: return render(request, 'dns/addDeleteDNSRecords.html', {"domainsList": domainsList, "status": 1}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def getCurrentRecordsForDomain(self, userID = None, data = None): @@ -233,7 +233,7 @@ class DNSManager: 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) @@ -406,7 +406,7 @@ class DNSManager: final_json = json.dumps(final_dic) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'add_status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -436,7 +436,7 @@ class DNSManager: final_json = json.dumps(final_dic) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'delete_status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -456,7 +456,7 @@ class DNSManager: return render(request, 'dns/deleteDNSZone.html', {"domainsList": domainsList, "status": 1}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def submitZoneDeletion(self, userID = None, data = None): @@ -486,7 +486,7 @@ class DNSManager: final_json = json.dumps(final_dic) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'delete_status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -529,7 +529,7 @@ class DNSManager: return render(request, 'dns/configureDefaultNameServers.html', data) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) @@ -568,7 +568,7 @@ class DNSManager: final_json = json.dumps(final_dic) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) \ No newline at end of file diff --git a/dns/models.py b/dns/models.py index c8b4e27ba..c926566db 100755 --- a/dns/models.py +++ b/dns/models.py @@ -1,4 +1,4 @@ -from __future__ import unicode_literals + from django.db import models from loginSystem.models import Administrator diff --git a/dns/tests.py b/dns/tests.py index 5982e6bcd..f067dcaac 100755 --- a/dns/tests.py +++ b/dns/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.test import TestCase diff --git a/dns/views.py b/dns/views.py index 9c2608ae6..1809c9a17 100755 --- a/dns/views.py +++ b/dns/views.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.shortcuts import redirect from loginSystem.views import loadLoginPage from dnsManager import DNSManager diff --git a/dockerManager/admin.py b/dockerManager/admin.py index 13be29d96..4c33e0ec3 100755 --- a/dockerManager/admin.py +++ b/dockerManager/admin.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.contrib import admin diff --git a/dockerManager/apps.py b/dockerManager/apps.py index b8b50bdb2..428bfbf77 100755 --- a/dockerManager/apps.py +++ b/dockerManager/apps.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.apps import AppConfig diff --git a/dockerManager/container.py b/dockerManager/container.py index 6a5606848..f4edd02e8 100755 --- a/dockerManager/container.py +++ b/dockerManager/container.py @@ -1,5 +1,5 @@ #!/usr/local/CyberCP/bin/python2 -from __future__ import division + import os import os.path import sys @@ -57,7 +57,7 @@ class ContainerManager(multi.Thread): elif self.function == 'restartGunicorn': command = 'sudo systemctl restart gunicorn.socket' ProcessUtilities.executioner(command) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + ' [ContainerManager.run]') @staticmethod @@ -68,7 +68,7 @@ class ContainerManager(multi.Thread): return 0 else: return 1 - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) return 0 @@ -87,7 +87,7 @@ class ContainerManager(multi.Thread): time.sleep(2) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, str(msg) + ' [404].', 1) def createContainer(self, request=None, userID=None, data=None): @@ -123,7 +123,7 @@ class ContainerManager(multi.Thread): for item in inspectImage['Config']['Env']: if '=' in item: splitedItem = item.split('=', 1) - print splitedItem + print(splitedItem) envList[splitedItem[0]] = splitedItem[1] else: envList[item] = "" @@ -142,7 +142,7 @@ class ContainerManager(multi.Thread): return render(request, 'dockerManager/runContainer.html', Data) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def loadContainerHome(self, request=None, userID=None, data=None): @@ -239,7 +239,7 @@ class ContainerManager(multi.Thread): "unlistedContainers": unlistedContainers, "adminNames": adminNames, "showUnlistedContainer": showUnlistedContainer}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def getContainerLogs(self, userID=None, data=None): @@ -262,7 +262,7 @@ class ContainerManager(multi.Thread): return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'containerLogStatus': 0, 'containerLog': 'Error', 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -290,7 +290,7 @@ class ContainerManager(multi.Thread): # Formatting envList for usage envDict = {} - for key, value in envList.iteritems(): + for key, value in envList.items(): if (value['name'] != '') or (value['value'] != ''): envDict[value['name']] = value['value'] @@ -304,7 +304,7 @@ class ContainerManager(multi.Thread): portConfig[item] = data[item] volumes = {} - for index, volume in volList.iteritems(): + for index, volume in volList.items(): volumes[volume['src']] = {'bind': volume['dest'], 'mode': 'rw'} @@ -325,7 +325,7 @@ class ContainerManager(multi.Thread): container = client.containers.create(**containerArgs) except Exception as err: if "port is already allocated" in err: # We need to delete container if port is not available - print "Deleting container" + print("Deleting container") container.remove(force=True) data_ret = {'createContainerStatus': 0, 'error_message': str(err)} json_data = json.dumps(data_ret) @@ -348,7 +348,7 @@ class ContainerManager(multi.Thread): return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'createContainerStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -376,7 +376,7 @@ class ContainerManager(multi.Thread): try: image = client.images.pull(image, tag=tag) - print image.id + print(image.id) except docker.errors.APIError as msg: data_ret = {'installImageStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) @@ -387,7 +387,7 @@ class ContainerManager(multi.Thread): return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'installImageStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -457,7 +457,7 @@ class ContainerManager(multi.Thread): json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: if called: return str(msg) else: @@ -477,7 +477,7 @@ class ContainerManager(multi.Thread): final_dic = {'listContainerStatus': 1, 'error_message': "None", "data": json_data} final_json = json.dumps(final_dic) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: dic = {'listContainerStatus': 0, 'error_message': str(msg)} json_data = json.dumps(dic) return HttpResponse(json_data) @@ -551,7 +551,7 @@ class ContainerManager(multi.Thread): json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'containerActionStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -581,7 +581,7 @@ class ContainerManager(multi.Thread): json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'containerStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -611,7 +611,7 @@ class ContainerManager(multi.Thread): response['Content-Disposition'] = 'attachment; filename="' + name + '.tar"' return response - except BaseException, msg: + except BaseException as msg: data_ret = {'containerStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -647,7 +647,7 @@ class ContainerManager(multi.Thread): json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'containerTopStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -688,7 +688,7 @@ class ContainerManager(multi.Thread): json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'assignContainerStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -714,7 +714,7 @@ class ContainerManager(multi.Thread): json_data = json.dumps(data_ret) return HttpResponse(json_data) - print json.dumps(matches) + print(json.dumps(matches)) for image in matches: if "/" in image['name']: @@ -726,7 +726,7 @@ class ContainerManager(multi.Thread): json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'searchImageStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -763,7 +763,7 @@ class ContainerManager(multi.Thread): getTag = tag.split(":") if len(getTag) == 2: tags.append(getTag[1]) - print tags + print(tags) if name in names: images[name]['tags'].extend(tags) else: @@ -776,7 +776,7 @@ class ContainerManager(multi.Thread): return render(request, 'dockerManager/images.html', {"images": images, "test": ''}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def manageImages(self, request=None, userID=None, data=None): @@ -810,7 +810,7 @@ class ContainerManager(multi.Thread): return render(request, 'dockerManager/manageImages.html', {"images": images}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def getImageHistory(self, userID=None, data=None): @@ -836,7 +836,7 @@ class ContainerManager(multi.Thread): json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'imageHistoryStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -857,7 +857,7 @@ class ContainerManager(multi.Thread): action = client.images.prune() else: action = client.images.remove(name) - print action + print(action) except docker.errors.APIError as err: data_ret = {'removeImageStatus': 0, 'error_message': str(err)} json_data = json.dumps(data_ret) @@ -871,7 +871,7 @@ class ContainerManager(multi.Thread): json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'removeImageStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -917,7 +917,7 @@ class ContainerManager(multi.Thread): con.save() return 0 - except BaseException, msg: + except BaseException as msg: return str(msg) def saveContainerSettings(self, userID=None, data=None): @@ -967,12 +967,12 @@ class ContainerManager(multi.Thread): if 'envConfirmation' in data and data['envConfirmation']: # Formatting envList for usage envDict = {} - for key, value in envList.iteritems(): + for key, value in envList.items(): if (value['name'] != '') or (value['value'] != ''): envDict[value['name']] = value['value'] volumes = {} - for index, volume in volList.iteritems(): + for index, volume in volList.items(): if volume['src'] == '' or volume['dest'] == '': continue volumes[volume['src']] = {'bind': volume['dest'], @@ -1003,7 +1003,7 @@ class ContainerManager(multi.Thread): json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'saveSettingsStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -1053,7 +1053,7 @@ class ContainerManager(multi.Thread): json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'recreateContainerStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -1073,7 +1073,7 @@ class ContainerManager(multi.Thread): else: image2 = "library/" + image - print image + print(image) registryData = requests.get('https://registry.hub.docker.com/v2/repositories/' + image2 + '/tags', {'page': page}).json() @@ -1084,7 +1084,7 @@ class ContainerManager(multi.Thread): data_ret = {'getTagsStatus': 1, 'list': tagList, 'next': registryData['next'], 'error_message': None} json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'getTagsStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) \ No newline at end of file diff --git a/dockerManager/decorators.py b/dockerManager/decorators.py index bd06190c7..74645d2de 100755 --- a/dockerManager/decorators.py +++ b/dockerManager/decorators.py @@ -38,7 +38,7 @@ def preDockerRun(function): try: client = docker.from_env() client.ping() - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg)) if isPost: data_ret = {'status': 0, 'error_message': 'Docker daemon not running or not responsive'} diff --git a/dockerManager/dockerInstall.py b/dockerManager/dockerInstall.py index 66d6ce51f..b0993a0a4 100755 --- a/dockerManager/dockerInstall.py +++ b/dockerManager/dockerInstall.py @@ -39,7 +39,7 @@ class DockerInstall: time.sleep(2) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, str(msg) + ' [404].', 1) DockerInstall.submitInstallDocker() \ No newline at end of file diff --git a/dockerManager/models.py b/dockerManager/models.py index 75d7328bc..554a808e4 100755 --- a/dockerManager/models.py +++ b/dockerManager/models.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models from loginSystem.models import Administrator diff --git a/dockerManager/tests.py b/dockerManager/tests.py index 5982e6bcd..f067dcaac 100755 --- a/dockerManager/tests.py +++ b/dockerManager/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.test import TestCase diff --git a/dockerManager/views.py b/dockerManager/views.py index fed61d06b..b686d0108 100755 --- a/dockerManager/views.py +++ b/dockerManager/views.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.shortcuts import render, redirect, HttpResponse from loginSystem.models import Administrator @@ -48,7 +48,7 @@ def installDocker(request): json_data = json.dumps(data_ret) 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) diff --git a/emailMarketing/admin.py b/emailMarketing/admin.py index 13be29d96..4c33e0ec3 100755 --- a/emailMarketing/admin.py +++ b/emailMarketing/admin.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.contrib import admin diff --git a/emailMarketing/apps.py b/emailMarketing/apps.py index dafe02fc4..251980df4 100755 --- a/emailMarketing/apps.py +++ b/emailMarketing/apps.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.apps import AppConfig diff --git a/emailMarketing/emailMarketing.py b/emailMarketing/emailMarketing.py index ba9d1b9a4..3071ccb78 100755 --- a/emailMarketing/emailMarketing.py +++ b/emailMarketing/emailMarketing.py @@ -1,5 +1,5 @@ #!/usr/local/CyberCP/bin/python2 -from __future__ import absolute_import + import os import time import csv @@ -28,7 +28,7 @@ class emailMarketing(multi.Thread): self.verificationJob() elif self.function == 'startEmailJob': self.startEmailJob() - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + ' [emailMarketing.run]') def createEmailList(self): @@ -58,7 +58,7 @@ class emailMarketing(multi.Thread): newEmail.save() logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'], str(counter) + ' emails read.') counter = counter + 1 - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) continue elif self.extraArgs['path'].endswith('.txt'): @@ -69,7 +69,7 @@ class emailMarketing(multi.Thread): if re.match('^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$', email) != None: try: getEmail = EmailsInList.objects.get(owner=newList, email=email) - except BaseException, msg: + except BaseException as msg: newEmail = EmailsInList(owner=newList, email=email, verificationStatus='NOT CHECKED', dateCreated=time.strftime("%I-%M-%S-%a-%b-%Y")) newEmail.save() @@ -78,7 +78,7 @@ class emailMarketing(multi.Thread): emails = emailsList.readline() logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'], str(counter) + 'Successfully read all emails. [200]') - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'], str(msg) +'. [404]') return 0 @@ -132,14 +132,14 @@ class emailMarketing(multi.Thread): logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, str(counter) + ' emails verified so far..') counter = counter + 1 - except BaseException, msg: + except BaseException as msg: items.verificationStatus = 'Verification Failed' items.save() counter = counter + 1 logging.CyberCPLogFileWriter.writeToFile(str(msg)) logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, str(counter) + ' emails successfully verified. [200]') - except BaseException, msg: + except BaseException as msg: verificationList = EmailLists.objects.get(listName=self.extraArgs['listName']) domain = verificationList.owner.domain tempStatusPath = '/home/cyberpanel/' + domain + "/" + self.extraArgs['listName'] @@ -235,7 +235,7 @@ class emailMarketing(multi.Thread): logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'], 'Successfully sent: ' + str(sent) + ' Failed: ' + str( failed)) - except BaseException, msg: + except BaseException as msg: failed = failed + 1 logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'], 'Successfully sent: ' + str( @@ -250,6 +250,6 @@ class emailMarketing(multi.Thread): logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'], 'Email job completed. [200]') - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'], str(msg) + '. [404]') return 0 \ No newline at end of file diff --git a/emailMarketing/emailMarketingManager.py b/emailMarketing/emailMarketingManager.py index 53f2f8d56..eb59339be 100755 --- a/emailMarketing/emailMarketingManager.py +++ b/emailMarketing/emailMarketingManager.py @@ -30,7 +30,7 @@ class EmailMarketingManager: return ACLManager.loadError() return render(self.request, 'emailMarketing/emailMarketing.html') - except KeyError, msg: + except KeyError as msg: return redirect(loadLoginPage) def fetchUsers(self): @@ -74,7 +74,7 @@ class EmailMarketingManager: data_ret = {"status": 1, 'data': json_data} json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -103,7 +103,7 @@ class EmailMarketingManager: data_ret = {"status": 1} json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -123,7 +123,7 @@ class EmailMarketingManager: return ACLManager.loadError() return render(self.request, 'emailMarketing/createEmailList.html', {'domain': self.domain}) - except KeyError, msg: + except KeyError as msg: return redirect(loadLoginPage) def submitEmailList(self): @@ -157,7 +157,7 @@ class EmailMarketingManager: data_ret = {"status": 1, 'tempStatusPath': extraArgs['tempStatusPath']} json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -178,7 +178,7 @@ class EmailMarketingManager: listNames = emACL.getEmailsLists(self.domain) return render(self.request, 'emailMarketing/manageLists.html', {'listNames': listNames, 'domain': self.domain}) - except KeyError, msg: + except KeyError as msg: return redirect(loadLoginPage) def fetchEmails(self): @@ -251,7 +251,7 @@ class EmailMarketingManager: data_ret = {"status": 1, 'data': json_data, 'pagination': pagination} json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -281,7 +281,7 @@ class EmailMarketingManager: data_ret = {"status": 1} json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -314,7 +314,7 @@ class EmailMarketingManager: data_ret = {"status": 1} json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -344,7 +344,7 @@ class EmailMarketingManager: data_ret = {"status": 1} json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -370,7 +370,7 @@ class EmailMarketingManager: for items in emailLists: listNames.append(items.listName) return render(self.request, 'emailMarketing/manageSMTPHosts.html', {'listNames': listNames, 'domain': self.domain}) - except KeyError, msg: + except KeyError as msg: return redirect(loadLoginPage) def saveSMTPHost(self): @@ -420,7 +420,7 @@ class EmailMarketingManager: data_ret = {"status": 1} json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -463,7 +463,7 @@ class EmailMarketingManager: data_ret = {"status": 1, 'data': json_data} json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -515,7 +515,7 @@ class EmailMarketingManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -529,7 +529,7 @@ class EmailMarketingManager: return ACLManager.loadErrorJson() return render(self.request, 'emailMarketing/composeMessages.html') - except KeyError, msg: + except KeyError as msg: return redirect(loadLoginPage) def saveEmailTemplate(self): @@ -557,7 +557,7 @@ class EmailMarketingManager: data_ret = {"status": 1} json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -581,7 +581,7 @@ class EmailMarketingManager: Data['hostNames'] = hostNames Data['listNames'] = listNames return render(self.request, 'emailMarketing/sendEmails.html', Data) - except KeyError, msg: + except KeyError as msg: return redirect(loadLoginPage) def templatePreview(self): @@ -597,7 +597,7 @@ class EmailMarketingManager: return ACLManager.loadError() return HttpResponse(template.emailMessage) - except KeyError, msg: + except KeyError as msg: return redirect(loadLoginPage) def fetchJobs(self): @@ -647,7 +647,7 @@ class EmailMarketingManager: data_ret = {"status": 1, 'data': json_data} json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -689,7 +689,7 @@ class EmailMarketingManager: data_ret = {"status": 1, 'tempStatusPath': extraArgs['tempStatusPath']} json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -714,7 +714,7 @@ class EmailMarketingManager: data_ret = {"status": 1} json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -734,7 +734,7 @@ class EmailMarketingManager: data_ret = {"status": 1} json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) diff --git a/emailMarketing/models.py b/emailMarketing/models.py index cda9ff5aa..0feff9f23 100755 --- a/emailMarketing/models.py +++ b/emailMarketing/models.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models from websiteFunctions.models import Websites diff --git a/emailMarketing/tests.py b/emailMarketing/tests.py index 5982e6bcd..f067dcaac 100755 --- a/emailMarketing/tests.py +++ b/emailMarketing/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.test import TestCase diff --git a/emailMarketing/views.py b/emailMarketing/views.py index 76be7dd8f..afcb46055 100755 --- a/emailMarketing/views.py +++ b/emailMarketing/views.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.shortcuts import redirect from loginSystem.views import loadLoginPage from emailMarketingManager import EmailMarketingManager diff --git a/emailPremium/admin.py b/emailPremium/admin.py index 13be29d96..4c33e0ec3 100755 --- a/emailPremium/admin.py +++ b/emailPremium/admin.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.contrib import admin diff --git a/emailPremium/apps.py b/emailPremium/apps.py index 69075763f..a4bed0ef2 100755 --- a/emailPremium/apps.py +++ b/emailPremium/apps.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.apps import AppConfig diff --git a/emailPremium/models.py b/emailPremium/models.py index 60e4ca5b6..7235a6161 100755 --- a/emailPremium/models.py +++ b/emailPremium/models.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models from mailServer.models import Domains, EUsers diff --git a/emailPremium/tests.py b/emailPremium/tests.py index 5982e6bcd..f067dcaac 100755 --- a/emailPremium/tests.py +++ b/emailPremium/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.test import TestCase diff --git a/emailPremium/views.py b/emailPremium/views.py index 1ba9a7ab7..32ac11772 100755 --- a/emailPremium/views.py +++ b/emailPremium/views.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.shortcuts import render,redirect from django.http import HttpResponse @@ -13,7 +13,7 @@ import json from .models import DomainLimits, EmailLimits from math import ceil from postfixSenderPolicy.client import cacheClient -import thread +import _thread from plogical.mailUtilities import mailUtilities from plogical.virtualHostUtilities import virtualHostUtilities from random import randint @@ -67,12 +67,12 @@ def fetchPolicyServerStatus(request): 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) - except KeyError,msg: + except KeyError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) data_ret = {'status': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) @@ -115,12 +115,12 @@ def savePolicyServerStatus(request): 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) - except KeyError,msg: + except KeyError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) data_ret = {'status': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) @@ -174,7 +174,7 @@ def listDomains(request): return render(request,'emailPremium/listDomains.html',{"pagination":pagination, "installCheck": installCheck}) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) return HttpResponse("See CyberCP main log file.") @@ -200,7 +200,7 @@ def getFurtherDomains(request): status = data['page'] pageNumber = int(status) - except BaseException, msg: + except BaseException as msg: status = str(msg) finalPageNumber = ((pageNumber * 10)) - 10 @@ -224,7 +224,7 @@ def getFurtherDomains(request): checker = 1 else: json_data = json_data +',' + json.dumps(dic) - except BaseException, msg: + except BaseException as msg: try: domain = Domains.objects.get(domainOwner=items) except: @@ -249,13 +249,13 @@ def getFurtherDomains(request): final_json = json.dumps(final_dic) return HttpResponse(final_json) - except BaseException,msg: + except BaseException as msg: dic = {'listWebSiteStatus': 0, 'error_message': str(msg)} json_data = json.dumps(dic) return HttpResponse(json_data) - except KeyError,msg: + except KeyError as msg: dic = {'listWebSiteStatus': 0, 'error_message': str(msg)} json_data = json.dumps(dic) return HttpResponse(json_data) @@ -292,13 +292,13 @@ def enableDisableEmailLimits(request): json_data = json.dumps(dic) return HttpResponse(json_data) - except BaseException,msg: + except BaseException as msg: dic = {'status': 0, 'error_message': str(msg)} json_data = json.dumps(dic) return HttpResponse(json_data) - except KeyError,msg: + except KeyError as msg: dic = {'statusa': 0, 'error_message': str(msg)} json_data = json.dumps(dic) return HttpResponse(json_data) @@ -385,13 +385,13 @@ def changeDomainLimit(request): json_data = json.dumps(dic) return HttpResponse(json_data) - except BaseException,msg: + except BaseException as msg: dic = {'status': 0, 'error_message': str(msg)} json_data = json.dumps(dic) return HttpResponse(json_data) - except KeyError,msg: + except KeyError as msg: dic = {'statusa': 0, 'error_message': str(msg)} json_data = json.dumps(dic) return HttpResponse(json_data) @@ -435,7 +435,7 @@ def getFurtherEmail(request): checker = 1 else: json_data = json_data +',' + json.dumps(dic) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) json_data = json_data + ']' @@ -445,13 +445,13 @@ def getFurtherEmail(request): 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) - except KeyError,msg: + except KeyError as msg: dic = {'status': 0, 'error_message': str(msg)} json_data = json.dumps(dic) return HttpResponse(json_data) @@ -484,12 +484,12 @@ def enableDisableIndividualEmailLimits(request): json_data = json.dumps(dic) return HttpResponse(json_data) - except BaseException,msg: + except BaseException as msg: dic = {'status': 0, 'error_message': str(msg)} json_data = json.dumps(dic) return HttpResponse(json_data) - except KeyError,msg: + except KeyError as msg: dic = {'statusa': 0, 'error_message': str(msg)} json_data = json.dumps(dic) return HttpResponse(json_data) @@ -558,13 +558,13 @@ def getEmailStats(request): 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) - except KeyError,msg: + except KeyError as msg: dic = {'status': 0, 'error_message': str(msg)} json_data = json.dumps(dic) return HttpResponse(json_data) @@ -597,12 +597,12 @@ def enableDisableIndividualEmailLogs(request): json_data = json.dumps(dic) return HttpResponse(json_data) - except BaseException,msg: + except BaseException as msg: dic = {'status': 0, 'error_message': str(msg)} json_data = json.dumps(dic) return HttpResponse(json_data) - except KeyError,msg: + except KeyError as msg: dic = {'statusa': 0, 'error_message': str(msg)} json_data = json.dumps(dic) return HttpResponse(json_data) @@ -668,13 +668,13 @@ def changeDomainEmailLimitsIndividual(request): json_data = json.dumps(dic) return HttpResponse(json_data) - except BaseException,msg: + except BaseException as msg: dic = {'status': 0, 'error_message': str(msg)} json_data = json.dumps(dic) return HttpResponse(json_data) - except KeyError,msg: + except KeyError as msg: dic = {'statusa': 0, 'error_message': str(msg)} json_data = json.dumps(dic) return HttpResponse(json_data) @@ -722,13 +722,13 @@ def getEmailLogs(request): 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) - except KeyError,msg: + except KeyError as msg: dic = {'status': 0, 'error_message': str(msg)} json_data = json.dumps(dic) return HttpResponse(json_data) @@ -757,12 +757,12 @@ def flushEmailLogs(request): json_data = json.dumps(dic) return HttpResponse(json_data) - except BaseException,msg: + except BaseException as msg: dic = {'status': 0, 'error_message': str(msg)} json_data = json.dumps(dic) return HttpResponse(json_data) - except KeyError,msg: + except KeyError as msg: dic = {'statusa': 0, 'error_message': str(msg)} json_data = json.dumps(dic) return HttpResponse(json_data) @@ -807,7 +807,7 @@ def installSpamAssassin(request): final_json = json.dumps({'status': 1, 'error_message': "None"}) return HttpResponse(final_json) - except BaseException,msg: + except BaseException as msg: final_dic = {'status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -865,7 +865,7 @@ def installStatusSpamAssassin(request): 'requestStatus': installStatus, }) return HttpResponse(final_json) - except BaseException,msg: + except BaseException as msg: final_dic = {'abort':1,'installed':0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -942,7 +942,7 @@ def fetchSpamAssassinSettings(request): 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) @@ -1011,12 +1011,12 @@ def saveSpamAssassinConfigurations(request): return HttpResponse(json_data) - except BaseException,msg: + except BaseException as msg: data_ret = {'saveStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) - except KeyError,msg: + except KeyError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) data_ret = {'saveStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) diff --git a/examplePlugin/admin.py b/examplePlugin/admin.py index 13be29d96..4c33e0ec3 100755 --- a/examplePlugin/admin.py +++ b/examplePlugin/admin.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.contrib import admin diff --git a/examplePlugin/apps.py b/examplePlugin/apps.py index daac439e9..cad74d831 100755 --- a/examplePlugin/apps.py +++ b/examplePlugin/apps.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.apps import AppConfig diff --git a/examplePlugin/models.py b/examplePlugin/models.py index 1dfab7604..4e6a8e76d 100755 --- a/examplePlugin/models.py +++ b/examplePlugin/models.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models diff --git a/examplePlugin/tests.py b/examplePlugin/tests.py index 5982e6bcd..f067dcaac 100755 --- a/examplePlugin/tests.py +++ b/examplePlugin/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.test import TestCase diff --git a/examplePlugin/views.py b/examplePlugin/views.py index c8c4e619e..d0790aff2 100755 --- a/examplePlugin/views.py +++ b/examplePlugin/views.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.shortcuts import render, HttpResponse diff --git a/filemanager/admin.py b/filemanager/admin.py index 13be29d96..4c33e0ec3 100755 --- a/filemanager/admin.py +++ b/filemanager/admin.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.contrib import admin diff --git a/filemanager/apps.py b/filemanager/apps.py index 7e758eb48..3bc634ff0 100755 --- a/filemanager/apps.py +++ b/filemanager/apps.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.apps import AppConfig diff --git a/filemanager/filemanager.py b/filemanager/filemanager.py index dc3286a05..ca00a322f 100755 --- a/filemanager/filemanager.py +++ b/filemanager/filemanager.py @@ -6,7 +6,7 @@ from plogical.processUtilities import ProcessUtilities from websiteFunctions.models import Websites from random import randint from django.core.files.storage import FileSystemStorage -import HTMLParser +import html.parser import os class FileManager: @@ -21,7 +21,7 @@ class FileManager: return HttpResponse(final_json) def returnPathEnclosed(self, path): - htmlParser = HTMLParser.HTMLParser() + htmlParser = html.parser.HTMLParser() path = htmlParser.unescape(path) return path return "'" + path + "'" @@ -55,7 +55,7 @@ class FileManager: for items in output: try: currentFile = items.split(' ') - currentFile = filter(lambda a: a != '', currentFile) + currentFile = [a for a in currentFile if a != ''] if currentFile[-1] == '.' or currentFile[-1] == '..' or currentFile[0] == 'total': continue @@ -72,13 +72,13 @@ class FileManager: finalData[str(counter)] = [currentFile[-1], currentFile[-1], lastModified, size, currentFile[0], dirCheck] counter = counter + 1 - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg)) json_data = json.dumps(finalData) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def list(self): @@ -97,7 +97,7 @@ class FileManager: for items in output: try: currentFile = items.split(' ') - currentFile = filter(lambda a: a != '', currentFile) + currentFile = [a for a in currentFile if a != ''] if currentFile[-1] == '.' or currentFile[-1] == '..' or currentFile[0] == 'total': continue @@ -119,7 +119,7 @@ class FileManager: json_data = json.dumps(finalData) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def createNewFile(self): @@ -142,7 +142,7 @@ class FileManager: json_data = json.dumps(finalData) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def createNewFolder(self): @@ -160,7 +160,7 @@ class FileManager: json_data = json.dumps(finalData) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def deleteFolderOrFile(self): @@ -178,7 +178,7 @@ class FileManager: json_data = json.dumps(finalData) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def copy(self): @@ -212,7 +212,7 @@ class FileManager: json_data = json.dumps(finalData) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def move(self): @@ -238,7 +238,7 @@ class FileManager: json_data = json.dumps(finalData) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def rename(self): @@ -261,7 +261,7 @@ class FileManager: json_data = json.dumps(finalData) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def readFileContents(self): @@ -278,7 +278,7 @@ class FileManager: json_data = json.dumps(finalData) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def writeFileContents(self): @@ -313,7 +313,7 @@ class FileManager: json_data = json.dumps(finalData) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def upload(self): @@ -345,7 +345,7 @@ class FileManager: json_data = json.dumps(finalData) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def extract(self): @@ -372,7 +372,7 @@ class FileManager: json_data = json.dumps(finalData) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def compress(self): @@ -405,7 +405,7 @@ class FileManager: json_data = json.dumps(finalData) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def changePermissions(self): @@ -429,5 +429,5 @@ class FileManager: json_data = json.dumps(finalData) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) \ No newline at end of file diff --git a/filemanager/models.py b/filemanager/models.py index 1dfab7604..4e6a8e76d 100755 --- a/filemanager/models.py +++ b/filemanager/models.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models diff --git a/filemanager/tests.py b/filemanager/tests.py index 5982e6bcd..f067dcaac 100755 --- a/filemanager/tests.py +++ b/filemanager/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.test import TestCase diff --git a/filemanager/views.py b/filemanager/views.py index ec447d593..5170b8151 100755 --- a/filemanager/views.py +++ b/filemanager/views.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.shortcuts import render,redirect from loginSystem.models import Administrator @@ -70,7 +70,7 @@ def changePermissions(request): return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) data_ret = {'permissionsChanged': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) @@ -145,7 +145,7 @@ def controller(request): return fm.changePermissions() - except BaseException, msg: + except BaseException as msg: fm = FM(request, None) return fm.ajaxPre(0, str(msg)) diff --git a/firewall/firewallManager.py b/firewall/firewallManager.py index 8da1bc374..c99e152a6 100755 --- a/firewall/firewallManager.py +++ b/firewall/firewallManager.py @@ -35,7 +35,7 @@ class FirewallManager: return ACLManager.loadError() return render(request, 'firewall/index.html') - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def firewallHome(self, request = None, userID = None): @@ -48,7 +48,7 @@ class FirewallManager: return ACLManager.loadError() return render(request, 'firewall/firewall.html') - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def getCurrentRules(self, userID = None): @@ -84,7 +84,7 @@ class FirewallManager: 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) @@ -113,7 +113,7 @@ class FirewallManager: final_json = json.dumps(final_dic) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'add_status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -143,7 +143,7 @@ class FirewallManager: final_json = json.dumps(final_dic) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'delete_status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -171,7 +171,7 @@ class FirewallManager: final_json = json.dumps(final_dic) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'reload_status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -199,7 +199,7 @@ class FirewallManager: final_json = json.dumps(final_dic) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'start_status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -227,7 +227,7 @@ class FirewallManager: final_json = json.dumps(final_dic) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'stop_status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -254,7 +254,7 @@ class FirewallManager: final_json = json.dumps(final_dic) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -269,7 +269,7 @@ class FirewallManager: return ACLManager.loadError() return render(request, 'firewall/secureSSH.html') - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def getSSHConfigs(self, userID = None, data = None): @@ -348,7 +348,7 @@ class FirewallManager: final_json = json.dumps({'status': 1, 'error_message': "None", "data": json_data}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -399,7 +399,7 @@ class FirewallManager: FirewallUtilities.addRule('tcp', sshPort, "0.0.0.0/0") command = 'firewall-cmd --permanent --remove-service=ssh' ProcessUtilities.executioner(command) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) final_dic = {'status': 1, 'saveStatus': 1} @@ -410,7 +410,7 @@ class FirewallManager: final_json = json.dumps(final_dic) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0 ,'saveStatus': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -440,7 +440,7 @@ class FirewallManager: final_json = json.dumps(final_dic) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'delete_status': 0, 'error_mssage': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -476,7 +476,7 @@ class FirewallManager: final_json = json.dumps(final_dic) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'add_status': 0, 'error_mssage': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -508,7 +508,7 @@ class FirewallManager: modSecInstalled = 1 return render(request, 'firewall/modSecurity.html', {'modSecInstalled': modSecInstalled, 'OLS': OLS}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def installModSec(self, userID = None, data = None): @@ -530,7 +530,7 @@ class FirewallManager: final_json = json.dumps({'installModSec': 1, 'error_message': "None"}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'installModSec': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -585,7 +585,7 @@ class FirewallManager: }) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'abort': 1, 'installed': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -726,7 +726,7 @@ class FirewallManager: final_json = json.dumps(final_dic) 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) @@ -859,7 +859,7 @@ class FirewallManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'saveStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -891,7 +891,7 @@ class FirewallManager: return render(request, 'firewall/modSecurityRules.html', {'modSecInstalled': modSecInstalled}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def fetchModSecRules(self, userID = None, data = None): @@ -945,7 +945,7 @@ class FirewallManager: final_json = json.dumps(final_dic) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'modSecInstalled': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) @@ -983,7 +983,7 @@ class FirewallManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'saveStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -1016,7 +1016,7 @@ class FirewallManager: return render(request, 'firewall/modSecurityRulesPacks.html', {'modSecInstalled': modSecInstalled}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(msg) def getOWASPAndComodoStatus(self, userID = None, data = None): @@ -1096,7 +1096,7 @@ class FirewallManager: final_json = json.dumps(final_dic) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'modSecInstalled': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -1146,7 +1146,7 @@ class FirewallManager: json_data = json.dumps(data_ret) 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) @@ -1250,7 +1250,7 @@ class FirewallManager: 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) @@ -1288,7 +1288,7 @@ class FirewallManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'saveStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -1312,7 +1312,7 @@ class FirewallManager: except subprocess.CalledProcessError: csfInstalled = 0 return render(self.request,'firewall/csf.html', {'csfInstalled' : csfInstalled}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def installCSF(self): @@ -1336,7 +1336,7 @@ class FirewallManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException,msg: + except BaseException as msg: final_dic = {'installStatus': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -1379,7 +1379,7 @@ class FirewallManager: }) return HttpResponse(final_json) - except BaseException,msg: + except BaseException as msg: final_dic = {'abort':1, 'installed':0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -1404,7 +1404,7 @@ class FirewallManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException,msg: + except BaseException as msg: final_dic = {'installStatus': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -1433,7 +1433,7 @@ class FirewallManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException,msg: + except BaseException as msg: final_dic = {'fetchStatus': 0, 'error_message': 'CSF is not installed.'} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -1466,7 +1466,7 @@ class FirewallManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException,msg: + except BaseException as msg: final_dic = {'status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -1507,7 +1507,7 @@ class FirewallManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException,msg: + except BaseException as msg: final_dic = {'status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -1537,7 +1537,7 @@ class FirewallManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException,msg: + except BaseException as msg: final_dic = {'status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) diff --git a/ftp/admin.py b/ftp/admin.py index d54be6ff8..68f74225e 100755 --- a/ftp/admin.py +++ b/ftp/admin.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.contrib import admin import models diff --git a/ftp/apps.py b/ftp/apps.py index 07ececb09..9ec4a66a2 100755 --- a/ftp/apps.py +++ b/ftp/apps.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.apps import AppConfig diff --git a/ftp/ftpManager.py b/ftp/ftpManager.py index 64a0ebe68..8eb3df7a0 100755 --- a/ftp/ftpManager.py +++ b/ftp/ftpManager.py @@ -47,7 +47,7 @@ class FTPManager: return render(self.request, 'ftp/createFTPAccount.html', {'websiteList': websitesName, 'admin': admin.userName, "status": 1}) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) return HttpResponse(str(msg)) @@ -100,7 +100,7 @@ class FTPManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'creatFTPStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -120,7 +120,7 @@ class FTPManager: websitesName = ACLManager.findAllSites(currentACL, userID) return render(self.request, 'ftp/deleteFTPAccount.html', {'websiteList': websitesName, "status": 1}) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) return HttpResponse(str(msg)) @@ -161,7 +161,7 @@ class FTPManager: final_json = json.dumps({'fetchStatus': 1, 'error_message': "None", "data": json_data}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: data_ret = {'fetchStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -188,7 +188,7 @@ class FTPManager: final_json = json.dumps({'status': 1, 'deleteStatus': 1, 'error_message': "None"}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'deleteStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -207,7 +207,7 @@ class FTPManager: websitesName = ACLManager.findAllSites(currentACL, userID) return render(self.request, 'ftp/listFTPAccounts.html', {'websiteList': websitesName, "status": 1}) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) return HttpResponse(str(msg)) @@ -252,7 +252,7 @@ class FTPManager: 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) @@ -282,7 +282,7 @@ class FTPManager: data_ret = {'status': 1, 'changePasswordStatus': 1, 'error_message': "None"} json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'changePasswordStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) \ No newline at end of file diff --git a/ftp/tests.py b/ftp/tests.py index ecc405fcc..e2464a559 100755 --- a/ftp/tests.py +++ b/ftp/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.test import TestCase import json diff --git a/ftp/views.py b/ftp/views.py index 7ee5c996b..2e2c19383 100755 --- a/ftp/views.py +++ b/ftp/views.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.shortcuts import redirect from ftpManager import FTPManager from loginSystem.views import loadLoginPage diff --git a/highAvailability/admin.py b/highAvailability/admin.py index 13be29d96..4c33e0ec3 100755 --- a/highAvailability/admin.py +++ b/highAvailability/admin.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.contrib import admin diff --git a/highAvailability/apps.py b/highAvailability/apps.py index 1b1e13f4d..ae2d91b77 100755 --- a/highAvailability/apps.py +++ b/highAvailability/apps.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.apps import AppConfig diff --git a/highAvailability/haManager.py b/highAvailability/haManager.py index e83acc336..1e04fef23 100755 --- a/highAvailability/haManager.py +++ b/highAvailability/haManager.py @@ -30,7 +30,7 @@ class HAManager(multi.Thread): self.setupNode() elif self.function == 'addManager': self.setupNode() - except BaseException, msg: + except BaseException as msg: logging.writeToFile( str(msg) + ' [HAManager.run]') def setupNode(self): @@ -72,7 +72,7 @@ class HAManager(multi.Thread): mesg = 'Node successfully configured. [200]' logging.statusWriter(self.data['tempStatusPath'], mesg) - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg)) logging.statusWriter(self.data['tempStatusPath'], str(msg) + '. [404]') @@ -118,7 +118,7 @@ class HAManager(multi.Thread): return proc.ajax(1, None, data) - except BaseException, msg: + except BaseException as msg: proc = httpProc(self.request, None, None) return proc.ajax(0, None, str(msg)) @@ -142,7 +142,7 @@ class HAManager(multi.Thread): return proc.ajax(1, None) - except BaseException, msg: + except BaseException as msg: proc = httpProc(self.request, None, None) return proc.ajax(0, None, str(msg)) @@ -163,11 +163,11 @@ class HAManager(multi.Thread): result = subprocess.call(command, shell=True) if result != 0: logging.writeToFile(command + ' Failed.') - except BaseException, msg: + except BaseException as msg: logging.writeToFile(command + 'Failed.') return 0 - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg)) def setUpDataNode(self): @@ -194,7 +194,7 @@ class HAManager(multi.Thread): return proc.ajax(1, None) - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg)) proc = httpProc(self.request, None, None) return proc.ajax(0, str(msg)) @@ -227,7 +227,7 @@ class HAManager(multi.Thread): return proc.ajax(1, None) - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg)) proc = httpProc(self.request, None, None) return proc.ajax(0, str(msg)) diff --git a/highAvailability/models.py b/highAvailability/models.py index 1dfab7604..4e6a8e76d 100755 --- a/highAvailability/models.py +++ b/highAvailability/models.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models diff --git a/highAvailability/tests.py b/highAvailability/tests.py index 5982e6bcd..f067dcaac 100755 --- a/highAvailability/tests.py +++ b/highAvailability/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.test import TestCase diff --git a/highAvailability/views.py b/highAvailability/views.py index e784a0bd2..e2a525da4 100755 --- a/highAvailability/views.py +++ b/highAvailability/views.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.shortcuts import render diff --git a/install/firewallUtilities.py b/install/firewallUtilities.py index b4bfacd54..8884eae16 100755 --- a/install/firewallUtilities.py +++ b/install/firewallUtilities.py @@ -13,10 +13,10 @@ class FirewallUtilities: inst.preFlightsChecks.stdOut("Failed to apply rule: " + command + " Error #" + str(res), 1) return 0 - except OSError, msg: + except OSError as msg: inst.preFlightsChecks.stdOut("Failed to apply rule: " + command + " Error: " + str(msg), 1) return 0 - except ValueError, msg: + except ValueError as msg: inst.preFlightsChecks.stdOut("Failed to apply rule: " + command + " Error: " + str(msg), 1) return 0 diff --git a/install/install.py b/install/install.py index ccbbabe0c..0a55b370e 100755 --- a/install/install.py +++ b/install/install.py @@ -28,7 +28,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]): @@ -123,11 +123,11 @@ class preFlightsChecks: @staticmethod def stdOut(message, log=0, do_exit=0, code=os.EX_OK): 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 log: logging.InstallLog.writeToFile(message) @@ -200,7 +200,7 @@ class preFlightsChecks: writeToFile.writelines(varTmp) writeToFile.close() - except BaseException, msg: + except BaseException as msg: preFlightsChecks.stdOut('[ERROR] ' + str(msg)) return 0 @@ -259,7 +259,7 @@ class preFlightsChecks: preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt") os._exit(0) - except BaseException, msg: + except BaseException as msg: logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + "[checkIfSeLinuxDisabled]") logging.InstallLog.writeToFile('[ERROR] ' + "SELinux Check OK. [checkIfSeLinuxDisabled]") preFlightsChecks.stdOut('[ERROR] ' + "SELinux Check OK.") @@ -355,7 +355,7 @@ class preFlightsChecks: command = "mkdir -p /etc/letsencrypt/live/" preFlightsChecks.call(command, self.distro, command,command,1, 0, os.EX_OSERR) - except BaseException, msg: + except BaseException as msg: logging.InstallLog.writeToFile("[ERROR] setup_account_cyberpanel. " + str(msg)) def yum_update(self): @@ -705,7 +705,7 @@ class preFlightsChecks: command = 'apt-get -y install unzip' preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) - except BaseException, msg: + except BaseException as msg: logging.InstallLog.writeToFile('[ERROR] '+ str(msg) + " [install_unzip]") def install_zip(self): @@ -717,7 +717,7 @@ class preFlightsChecks: command = 'apt-get -y install zip' preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) - except BaseException, msg: + except BaseException as msg: logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [install_zip]") def download_install_phpmyadmin(self): @@ -734,7 +734,7 @@ class preFlightsChecks: ## 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() @@ -757,7 +757,7 @@ class preFlightsChecks: preFlightsChecks.call(command, self.distro, '[chown -R lscpd:lscpd /usr/local/CyberCP/public/phpmyadmin]', 'chown -R lscpd:lscpd /usr/local/CyberCP/public/phpmyadmin', 1, 0, os.EX_OSERR) - except BaseException, msg: + except BaseException as msg: logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [download_install_phpmyadmin]") return 0 @@ -859,7 +859,7 @@ enabled=1""" except: pass - except BaseException, msg: + except BaseException as msg: logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [install_postfix_davecot]") return 0 @@ -985,7 +985,7 @@ enabled=1""" logging.InstallLog.writeToFile("Authentication for Postfix and Dovecot set.") - except BaseException, msg: + except BaseException as msg: logging.InstallLog.writeToFile('[ERROR]' + str(msg) + " [setup_email_Passwords]") return 0 @@ -1239,7 +1239,7 @@ enabled=1""" preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) logging.InstallLog.writeToFile("Postfix and Dovecot configured") - except BaseException, msg: + except BaseException as msg: logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [setup_postfix_davecot_config]") return 0 @@ -1315,7 +1315,7 @@ imap_folder_list_limit = 0 writeToFile.close() - except BaseException, msg: + except BaseException as msg: logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [downoad_and_install_rainloop]") return 0 @@ -1332,7 +1332,7 @@ imap_folder_list_limit = 0 preFlightsChecks.stdOut("Checking to see if ufw firewall is installed (will be removed)", 1) status = subprocess.check_output(shlex.split('ufw status')) preFlightsChecks.stdOut("ufw current status: " + status + "...will be removed") - except BaseException, msg: + except BaseException as msg: preFlightsChecks.stdOut("[ERROR] Expected access to ufw not available, do not need to remove it", 1) return True try: @@ -1392,10 +1392,10 @@ imap_folder_list_limit = 0 preFlightsChecks.stdOut("FirewallD installed and configured!") - except OSError, msg: + except OSError as msg: logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [installFirewalld]") return 0 - except ValueError, msg: + except ValueError as msg: logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [installFirewalld]") return 0 @@ -1470,7 +1470,7 @@ imap_folder_list_limit = 0 logging.InstallLog.writeToFile("LSCPD successfully installed!") - except BaseException, msg: + except BaseException as msg: logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [installLSCPD]") def setupComodoRules(self): @@ -1556,7 +1556,7 @@ imap_folder_list_limit = 0 return 1 - except BaseException, msg: + except BaseException as msg: logging.InstallLog.writeToFile("[ERROR]" + str(msg)) return 0 @@ -1654,7 +1654,7 @@ imap_folder_list_limit = 0 logging.InstallLog.writeToFile("LSCPD Daemon Set!") - except BaseException, msg: + except BaseException as msg: logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [setupLSCPDDaemon]") return 0 @@ -1712,7 +1712,7 @@ imap_folder_list_limit = 0 preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) - except BaseException, msg: + except BaseException as msg: logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [setup_cron]") return 0 @@ -1726,7 +1726,7 @@ imap_folder_list_limit = 0 command = "ssh-keygen -f /root/.ssh/cyberpanel -t rsa -N ''" preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) - except BaseException, msg: + except BaseException as msg: logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [install_default_keys]") return 0 @@ -1739,7 +1739,7 @@ imap_folder_list_limit = 0 preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) - except BaseException, msg: + except BaseException as msg: logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [install_rsync]") return 0 @@ -1748,7 +1748,7 @@ imap_folder_list_limit = 0 import requests getVersion = requests.get('https://cyberpanel.net/version.txt') latest = getVersion.json() - except BaseException, msg: + except BaseException as msg: command = "pip uninstall --yes urllib3" preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) @@ -1770,7 +1770,7 @@ imap_folder_list_limit = 0 print(" ") print(" ") - print(" Visit: https://" + self.ipAddr + ":8090 ") + print((" Visit: https://" + self.ipAddr + ":8090 ")) print(" Username: admin ") print(" Password: 1234567 ") @@ -1782,7 +1782,7 @@ imap_folder_list_limit = 0 pathToRemoveGarbageFile = os.path.join(self.server_root_path, "modules/mod_security.so") os.remove(pathToRemoveGarbageFile) - except OSError, msg: + except OSError as msg: logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [modSecPreReqs]") return 0 @@ -1802,7 +1802,7 @@ imap_folder_list_limit = 0 command = 'mkdir -p /etc/opendkim/keys/' preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) - except BaseException, msg: + except BaseException as msg: logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [installOpenDKIM]") return 0 @@ -1866,7 +1866,7 @@ milter_default_action = accept preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) - except BaseException, msg: + except BaseException as msg: logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [configureOpenDKIM]") return 0 @@ -1904,7 +1904,7 @@ milter_default_action = accept command = "./composer.sh" preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) - except OSError, msg: + except OSError as msg: logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [setupPHPAndComposer]") return 0 @@ -1974,7 +1974,7 @@ milter_default_action = accept 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)) ## @@ -1998,7 +1998,7 @@ milter_default_action = accept command = "virtualenv --system-site-packages /usr/local/CyberCP" preFlightsChecks.call(command, distro, command, command, 1, 0, os.EX_OSERR) - except OSError, msg: + except OSError as msg: logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [setupVirtualEnv]") return 0 @@ -2024,7 +2024,7 @@ milter_default_action = accept writeToFile = open(servicePath, 'w+') writeToFile.close() - except OSError, msg: + except OSError as msg: logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [enableDisableDNS]") return 0 @@ -2050,7 +2050,7 @@ milter_default_action = accept writeToFile = open(servicePath, 'w+') writeToFile.close() - except OSError, msg: + except OSError as msg: logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [enableDisableEmail]") return 0 @@ -2076,7 +2076,7 @@ milter_default_action = accept writeToFile = open(servicePath, 'w+') writeToFile.close() - except OSError, msg: + except OSError as msg: logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [enableDisableEmail]") return 0 @@ -2106,7 +2106,7 @@ milter_default_action = accept 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') preFlightsChecks.call(command, distro, '[install python36]', @@ -2137,7 +2137,7 @@ milter_default_action = accept 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') preFlightsChecks.call(command, distro, '[install python36]', diff --git a/install/installCyberPanel.py b/install/installCyberPanel.py index 5c3e76d2c..8d16ca636 100755 --- a/install/installCyberPanel.py +++ b/install/installCyberPanel.py @@ -86,7 +86,7 @@ class InstallCyberPanel: command = 'chown -R lsadm:lsadm ' + confPath install.preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) - except BaseException, msg: + except BaseException as msg: logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [installLiteSpeed]") return 0 @@ -116,7 +116,7 @@ class InstallCyberPanel: writeDataToFile.close() InstallCyberPanel.stdOut("OpenLiteSpeed Configurations fixed!", 1) - except IOError, msg: + except IOError as msg: logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [fix_ols_configs]") return 0 @@ -140,7 +140,7 @@ class InstallCyberPanel: InstallCyberPanel.stdOut("Default port is now 80 for OpenLiteSpeed!", 1) - except IOError, msg: + except IOError as msg: logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [changePortTo80]") return 0 @@ -208,7 +208,7 @@ class InstallCyberPanel: InstallCyberPanel.stdOut("MariaDB repo set!", 1) - except BaseException, msg: + except BaseException as msg: logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [setup_mariadb_repo]") return 0 @@ -426,7 +426,7 @@ class InstallCyberPanel: InstallCyberPanel.stdOut("PureFTPD configured!", 1) - except IOError, msg: + except IOError as msg: logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [installPureFTPDConfigurations]") return 0 @@ -480,7 +480,7 @@ class InstallCyberPanel: install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) - except BaseException, msg: + except BaseException as msg: logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [powerDNS]") def installPowerDNSConfigurations(self, mysqlPassword, mysql): @@ -525,7 +525,7 @@ class InstallCyberPanel: InstallCyberPanel.stdOut("PowerDNS configured!", 1) - except IOError, msg: + except IOError as msg: logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [installPowerDNSConfigurations]") return 0 return 1 diff --git a/install/mysqlUtilities.py b/install/mysqlUtilities.py index bdab9c3d4..6599472d4 100755 --- a/install/mysqlUtilities.py +++ b/install/mysqlUtilities.py @@ -43,5 +43,5 @@ class mysqlUtilities: return 0 return 1 - except BaseException, msg: + except BaseException as msg: return 0 \ No newline at end of file diff --git a/install/randomPassword.py b/install/randomPassword.py index 2eb292e45..699ad3963 100755 --- a/install/randomPassword.py +++ b/install/randomPassword.py @@ -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]): diff --git a/install/unInstall.py b/install/unInstall.py index 5d14440c1..43838bb58 100755 --- a/install/unInstall.py +++ b/install/unInstall.py @@ -17,7 +17,7 @@ class unInstallCyberPanel: copyPath = "/etc/yum.repos.d/cyberpanel.repo" os.remove(copyPath) - except OSError,msg: + except OSError as msg: logging.InstallLog.writeToFile(str(msg)+ " [unInstallCyberPanelRepo]") def removeGunicorn(self): @@ -34,7 +34,7 @@ class unInstallCyberPanel: os.remove(conf) - except BaseException, msg: + except BaseException as msg: logging.InstallLog.writeToFile(str(msg) + " [removeGunicorn]") def removePostfixDovecot(self): @@ -50,10 +50,10 @@ class unInstallCyberPanel: shutil.rmtree("etc/dovecot") - except OSError, msg: + except OSError as msg: logging.InstallLog.writeToFile(str(msg) + " [removePostfixDovecot]") return 0 - except ValueError, msg: + except ValueError as msg: logging.InstallLog.writeToFile(str(msg) + " [removePostfixDovecot]") return 0 @@ -72,10 +72,10 @@ class unInstallCyberPanel: os.remove("/etc/my.cnf") - except OSError, msg: + except OSError as msg: logging.InstallLog.writeToFile(str(msg) + " [removeMysql]") return 0 - except ValueError, msg: + except ValueError as msg: logging.InstallLog.writeToFile(str(msg) + " [removeMysql]") return 0 @@ -92,10 +92,10 @@ class unInstallCyberPanel: shutil.rmtree("/usr/local/lsws") - except OSError, msg: + except OSError as msg: logging.InstallLog.writeToFile(str(msg) + " [removeLiteSpeed]") return 0 - except ValueError, msg: + except ValueError as msg: logging.InstallLog.writeToFile(str(msg) + " [removeLiteSpeed]") return 0 return 1 @@ -107,10 +107,10 @@ class unInstallCyberPanel: os.remove("/usr/local/CyberCP2.tar.gz") shutil.rmtree("/etc/cyberpanel") - except OSError, msg: + except OSError as msg: logging.InstallLog.writeToFile(str(msg) + " [removeCyberPanel]") return 0 - except ValueError, msg: + except ValueError as msg: logging.InstallLog.writeToFile(str(msg) + " [removeCyberPanel]") return 0 return 1 @@ -126,10 +126,10 @@ class unInstallCyberPanel: shutil.rmtree("/etc/pure-ftpd") - except OSError, msg: + except OSError as msg: logging.InstallLog.writeToFile(str(msg) + " [removePureFTPD]") return 0 - except ValueError, msg: + except ValueError as msg: logging.InstallLog.writeToFile(str(msg) + " [removePureFTPD]") return 0 return 1 @@ -145,10 +145,10 @@ class unInstallCyberPanel: shutil.rmtree("/etc/pdns") - except OSError, msg: + except OSError as msg: logging.InstallLog.writeToFile(str(msg) + " [removePowerDNS]") return 0 - except ValueError, msg: + except ValueError as msg: logging.InstallLog.writeToFile(str(msg) + " [removePowerDNS]") return 0 return 1 @@ -164,10 +164,10 @@ class unInstallCyberPanel: shutil.rmtree("/etc/pdns") - except OSError, msg: + except OSError as msg: logging.InstallLog.writeToFile(str(msg) + " [removePHP]") return 0 - except ValueError, msg: + except ValueError as msg: logging.InstallLog.writeToFile(str(msg) + " [removePHP]") return 0 return 1 diff --git a/loginSystem/admin.py b/loginSystem/admin.py index 0458fe2f6..1c228b8d5 100755 --- a/loginSystem/admin.py +++ b/loginSystem/admin.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.contrib import admin import models diff --git a/loginSystem/apps.py b/loginSystem/apps.py index b6b5fad7e..408639d32 100755 --- a/loginSystem/apps.py +++ b/loginSystem/apps.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.apps import AppConfig diff --git a/loginSystem/models.py b/loginSystem/models.py index c00538038..c63d999ca 100755 --- a/loginSystem/models.py +++ b/loginSystem/models.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models diff --git a/loginSystem/tests.py b/loginSystem/tests.py index 41600aa02..f0722b38b 100755 --- a/loginSystem/tests.py +++ b/loginSystem/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.test import TestCase, Client from django.urls import reverse diff --git a/loginSystem/views.py b/loginSystem/views.py index 18c3e2da8..8b84dbc25 100755 --- a/loginSystem/views.py +++ b/loginSystem/views.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.shortcuts import render from django.http import HttpResponse @@ -141,7 +141,7 @@ def verifyLogin(request): json_data = json.dumps(data) return HttpResponse(json_data) - except BaseException,msg: + except BaseException as msg: data = {'userID': 0, 'loginStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data) return HttpResponse(json_data) diff --git a/mailServer/admin.py b/mailServer/admin.py index 13be29d96..4c33e0ec3 100755 --- a/mailServer/admin.py +++ b/mailServer/admin.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.contrib import admin diff --git a/mailServer/apps.py b/mailServer/apps.py index 5ff6ef7af..f1b1eb3ad 100755 --- a/mailServer/apps.py +++ b/mailServer/apps.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.apps import AppConfig diff --git a/mailServer/mailserverManager.py b/mailServer/mailserverManager.py index 8e4173442..86caec7d6 100755 --- a/mailServer/mailserverManager.py +++ b/mailServer/mailserverManager.py @@ -16,7 +16,7 @@ import shlex import subprocess from plogical.virtualHostUtilities import virtualHostUtilities from plogical.mailUtilities import mailUtilities -import thread +import _thread from dns.models import Domains as dnsDomains from dns.models import Records as dnsRecords from mailServer.models import Forwardings, Pipeprograms @@ -56,7 +56,7 @@ class MailServerManager: return render(self.request, 'mailServer/createEmailAccount.html', {'websiteList': websitesName, "status": 1}) - except BaseException, msg: + except BaseException as msg: return redirect(loadLoginPage) @@ -76,7 +76,7 @@ class MailServerManager: return render(self.request, 'mailServer/listEmails.html', {'websiteList': websitesName, "status": 1}) - except BaseException, msg: + except BaseException as msg: return redirect(loadLoginPage) def submitEmailCreation(self): @@ -115,7 +115,7 @@ class MailServerManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'createEmailStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -137,7 +137,7 @@ class MailServerManager: return render(self.request, 'mailServer/deleteEmailAccount.html', {'websiteList': websitesName, "status": 1}) - except BaseException, msg: + except BaseException as msg: return redirect(loadLoginPage) def getEmailsForDomain(self): @@ -190,7 +190,7 @@ class MailServerManager: return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'fetchStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -221,7 +221,7 @@ class MailServerManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'deleteEmailStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -241,7 +241,7 @@ class MailServerManager: websitesName = websitesName + ACLManager.findChildDomains(websitesName) return render(self.request, 'mailServer/emailForwarding.html', {'websiteList': websitesName, "status": 1}) - except BaseException, msg: + except BaseException as msg: return redirect(loadLoginPage) def fetchCurrentForwardings(self): @@ -320,7 +320,7 @@ class MailServerManager: return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'fetchStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -373,7 +373,7 @@ class MailServerManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'deleteForwardingStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -449,7 +449,7 @@ class MailServerManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'createStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -495,7 +495,7 @@ class MailServerManager: 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) @@ -518,7 +518,7 @@ class MailServerManager: return render(self.request, 'mailServer/changeEmailPassword.html', {'websiteList': websitesName, "status": 1}) - except BaseException, msg: + except BaseException as msg: return redirect(loadLoginPage) def submitPasswordChange(self): @@ -563,7 +563,7 @@ class MailServerManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'passChangeStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -586,7 +586,7 @@ class MailServerManager: return render(self.request, 'mailServer/dkimManager.html', {'websiteList': websitesName, 'openDKIMInstalled': openDKIMInstalled}) - except BaseException, msg: + except BaseException as msg: return redirect(loadLoginPage) def fetchDKIMKeys(self): @@ -623,12 +623,12 @@ class MailServerManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 1, 'fetchStatus': 1, 'keysAvailable': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'fetchStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -694,7 +694,7 @@ class MailServerManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'generateStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -705,10 +705,10 @@ class MailServerManager: currentACL = ACLManager.loadedACL(userID) if ACLManager.currentContextPermission(currentACL, 'dkimManager') == 0: return ACLManager.loadErrorJson('installOpenDKIM', 0) - thread.start_new_thread(mailUtilities.installOpenDKIM, ('Install', 'openDKIM')) + _thread.start_new_thread(mailUtilities.installOpenDKIM, ('Install', 'openDKIM')) final_json = json.dumps({'installOpenDKIM': 1, 'error_message': "None"}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'installOpenDKIM': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -760,7 +760,7 @@ class MailServerManager: }) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'abort': 1, 'installed': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) diff --git a/mailServer/models.py b/mailServer/models.py index 7e3fe26e7..b190bc617 100755 --- a/mailServer/models.py +++ b/mailServer/models.py @@ -5,7 +5,7 @@ # * Make sure each ForeignKey has `on_delete` set to the desired behavior. # * Remove `managed = False` lines if you wish to allow Django to create, modify, and delete the table # Feel free to rename the models, but don't rename db_table values or field names. -from __future__ import unicode_literals + from django.db import models from websiteFunctions.models import Websites, ChildDomains diff --git a/mailServer/tests.py b/mailServer/tests.py index b5e055caf..7a144f59e 100755 --- a/mailServer/tests.py +++ b/mailServer/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.test import TestCase import json diff --git a/mailServer/views.py b/mailServer/views.py index 78d9b6ab9..cf0c2ad02 100755 --- a/mailServer/views.py +++ b/mailServer/views.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.shortcuts import redirect from django.http import HttpResponse @@ -66,7 +66,7 @@ def getEmailsForDomain(request): try: msM = MailServerManager(request) return msM.getEmailsForDomain() - except KeyError,msg: + except KeyError as msg: data_ret = {'fetchStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -86,7 +86,7 @@ def submitEmailDeletion(request): return result return coreResult - except KeyError,msg: + except KeyError as msg: data_ret = {'deleteEmailStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -102,7 +102,7 @@ def fetchCurrentForwardings(request): try: msM = MailServerManager(request) return msM.fetchCurrentForwardings() - except KeyError,msg: + except KeyError as msg: data_ret = {'fetchStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -122,7 +122,7 @@ def submitForwardDeletion(request): return result return coreResult - except KeyError,msg: + except KeyError as msg: data_ret = {'deleteEmailStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -142,7 +142,7 @@ def submitEmailForwardingCreation(request): return result return coreResult - except KeyError,msg: + except KeyError as msg: data_ret = {'createStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -171,7 +171,7 @@ def submitPasswordChange(request): return result return coreResult - except KeyError,msg: + except KeyError as msg: data_ret = {'passChangeStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -189,7 +189,7 @@ def fetchDKIMKeys(request): try: msM = MailServerManager(request) return msM.fetchDKIMKeys() - except KeyError,msg: + except KeyError as msg: data_ret = {'fetchStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -209,7 +209,7 @@ def generateDKIMKeys(request): return result return coreResult - except BaseException, msg: + except BaseException as msg: data_ret = {'generateStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) diff --git a/managePHP/admin.py b/managePHP/admin.py index 3ccc77a21..20da422e0 100755 --- a/managePHP/admin.py +++ b/managePHP/admin.py @@ -1,4 +1,4 @@ -from __future__ import unicode_literals + from django.contrib import admin import models diff --git a/managePHP/apps.py b/managePHP/apps.py index 0327fb030..f7161b6e4 100755 --- a/managePHP/apps.py +++ b/managePHP/apps.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.apps import AppConfig diff --git a/managePHP/models.py b/managePHP/models.py index 549cc49c7..6b00d2e33 100755 --- a/managePHP/models.py +++ b/managePHP/models.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models diff --git a/managePHP/tests.py b/managePHP/tests.py index 5982e6bcd..f067dcaac 100755 --- a/managePHP/tests.py +++ b/managePHP/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.test import TestCase diff --git a/managePHP/views.py b/managePHP/views.py index 5870349c4..cfba11d45 100755 --- a/managePHP/views.py +++ b/managePHP/views.py @@ -1,8 +1,9 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals -import sys -reload(sys) +import sys +import importlib + +importlib.reload(sys) sys.setdefaultencoding("utf-8") from django.shortcuts import render, redirect from loginSystem.views import loadLoginPage @@ -1247,7 +1248,7 @@ def getExtensionsInformation(request): 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) @@ -1286,7 +1287,7 @@ def submitExtensionRequest(request): final_json = json.dumps({'extensionRequestStatus': 1, 'error_message': "None"}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'extensionRequestStatus': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) @@ -1413,7 +1414,7 @@ def getRequestStatus(request): - except BaseException, msg: + except BaseException as msg: final_dic = {'extensionRequestStatus': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -1535,12 +1536,12 @@ def getRequestStatusApache(request): - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + ' [getRequestStatusApache]') final_dic = {'status': 0, 'extensionRequestStatus': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) - except KeyError, msg: + except KeyError as msg: logging.writeToFile(str(msg) + ' [getRequestStatusApache]') final_dic = {'status': 0, 'extensionRequestStatus': 0, 'error_message': "Not Logged In, please refresh the page or login again."} @@ -1639,7 +1640,7 @@ def getCurrentPHPConfig(request): 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) @@ -1712,7 +1713,7 @@ def savePHPConfigBasic(request): final_json = json.dumps(final_dic) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'saveStatus': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -1756,7 +1757,7 @@ def getCurrentAdvancedPHPConfig(request): 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) @@ -1810,11 +1811,11 @@ def savePHPConfigAdvance(request): json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'saveStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) - except KeyError, msg: + except KeyError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[saveConfigsToFile]") return HttpResponse("Not Logged in as admin") diff --git a/manageSSL/admin.py b/manageSSL/admin.py index 13be29d96..4c33e0ec3 100755 --- a/manageSSL/admin.py +++ b/manageSSL/admin.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.contrib import admin diff --git a/manageSSL/apps.py b/manageSSL/apps.py index 52532b43b..780a85252 100755 --- a/manageSSL/apps.py +++ b/manageSSL/apps.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.apps import AppConfig diff --git a/manageSSL/models.py b/manageSSL/models.py index 1dfab7604..4e6a8e76d 100755 --- a/manageSSL/models.py +++ b/manageSSL/models.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models diff --git a/manageSSL/tests.py b/manageSSL/tests.py index 3c3d87027..859e26504 100755 --- a/manageSSL/tests.py +++ b/manageSSL/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.test import TestCase import json diff --git a/manageSSL/views.py b/manageSSL/views.py index 99aa571d7..6c198aacc 100755 --- a/manageSSL/views.py +++ b/manageSSL/views.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.shortcuts import render, redirect from loginSystem.views import loadLoginPage @@ -102,7 +102,7 @@ def issueSSL(request): json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, "SSL": 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) @@ -180,7 +180,7 @@ def obtainHostNameSSL(request): ## ssl issue ends - except BaseException, msg: + except BaseException as msg: data_ret = {"status": 0, "SSL": 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) @@ -258,12 +258,12 @@ def obtainMailServerSSL(request): ## ssl issue ends - except BaseException, msg: + except BaseException as msg: data_ret = {"status": 0, "SSL": 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) - except KeyError, msg: + except KeyError as msg: data_ret = {"status": 0, "SSL": 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) diff --git a/manageServices/admin.py b/manageServices/admin.py index 13be29d96..4c33e0ec3 100755 --- a/manageServices/admin.py +++ b/manageServices/admin.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.contrib import admin diff --git a/manageServices/apps.py b/manageServices/apps.py index 5009166ee..2a09d9f00 100755 --- a/manageServices/apps.py +++ b/manageServices/apps.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.apps import AppConfig diff --git a/manageServices/models.py b/manageServices/models.py index e98e554a9..4b99127fa 100755 --- a/manageServices/models.py +++ b/manageServices/models.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models diff --git a/manageServices/tests.py b/manageServices/tests.py index 5982e6bcd..f067dcaac 100755 --- a/manageServices/tests.py +++ b/manageServices/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.test import TestCase diff --git a/manageServices/views.py b/manageServices/views.py index fb289eb3e..1a6b96549 100755 --- a/manageServices/views.py +++ b/manageServices/views.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.shortcuts import render from django.shortcuts import HttpResponse, redirect @@ -27,7 +27,7 @@ def managePowerDNS(request): try: return render(request, 'manageServices/managePowerDNS.html', {"status": 1}) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) return HttpResponse("See CyberCP main log file.") @@ -47,7 +47,7 @@ def managePostfix(request): return render(request, 'manageServices/managePostfix.html', {"status": 1}) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) return HttpResponse("See CyberCP main log file.") @@ -65,7 +65,7 @@ def managePureFtpd(request): return ACLManager.loadError() try: return render(request, 'manageServices/managePureFtpd.html', {"status": 1}) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) return HttpResponse("See CyberCP main log file.") @@ -125,12 +125,12 @@ def fetchStatus(request): json_data = json.dumps(data_ret) 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) - except KeyError,msg: + except KeyError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) data_ret = {'status': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) @@ -268,12 +268,12 @@ def saveStatus(request): 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) - except KeyError,msg: + except KeyError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) data_ret = {'status': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) diff --git a/packages/admin.py b/packages/admin.py index 87f306cac..dd4a2dda5 100755 --- a/packages/admin.py +++ b/packages/admin.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.contrib import admin diff --git a/packages/apps.py b/packages/apps.py index d99b934aa..57e12de16 100755 --- a/packages/apps.py +++ b/packages/apps.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.apps import AppConfig diff --git a/packages/models.py b/packages/models.py index 50a8931a7..ea0403ff5 100755 --- a/packages/models.py +++ b/packages/models.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from loginSystem.models import Administrator from django.db import models diff --git a/packages/packagesManager.py b/packages/packagesManager.py index 1a6ff8197..c730abf44 100755 --- a/packages/packagesManager.py +++ b/packages/packagesManager.py @@ -21,7 +21,7 @@ class PackagesManager: try: val = self.request.session['userID'] return render(self.request, 'packages/index.html', {}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def createPacakge(self): @@ -49,7 +49,7 @@ class PackagesManager: packageList = ACLManager.loadPackages(userID, currentACL) return render(self.request, 'packages/deletePackage.html', {"packageList": packageList}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def submitPackage(self): @@ -101,7 +101,7 @@ class PackagesManager: 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) @@ -125,7 +125,7 @@ class PackagesManager: return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'deleteStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -141,7 +141,7 @@ class PackagesManager: packageList = ACLManager.loadPackages(userID, currentACL) return render(self.request, 'packages/modifyPackage.html', {"packList": packageList}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def submitModify(self): @@ -170,7 +170,7 @@ class PackagesManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'modifyStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -215,7 +215,7 @@ class PackagesManager: 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) @@ -232,7 +232,7 @@ class PackagesManager: packageList = ACLManager.loadPackages(userID, currentACL) return render(self.request, 'packages/listPackages.html', {"packList": packageList}) - except BaseException, msg: + except BaseException as msg: return redirect(loadLoginPage) def fetchPackagesTable(self): diff --git a/packages/tests.py b/packages/tests.py index b4d828661..a41602834 100755 --- a/packages/tests.py +++ b/packages/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.test import TestCase import json diff --git a/packages/views.py b/packages/views.py index 731244329..db4e6fe75 100755 --- a/packages/views.py +++ b/packages/views.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.shortcuts import redirect from loginSystem.views import loadLoginPage diff --git a/plogical/CyberCPLogFileWriter.py b/plogical/CyberCPLogFileWriter.py index 449a321a9..254296922 100755 --- a/plogical/CyberCPLogFileWriter.py +++ b/plogical/CyberCPLogFileWriter.py @@ -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) diff --git a/plogical/acl.py b/plogical/acl.py index 679c8e367..6b5c871ff 100755 --- a/plogical/acl.py +++ b/plogical/acl.py @@ -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) diff --git a/plogical/applicationInstaller.py b/plogical/applicationInstaller.py index bba893afa..88c2dd42a 100755 --- a/plogical/applicationInstaller.py +++ b/plogical/applicationInstaller.py @@ -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" diff --git a/plogical/backupManager.py b/plogical/backupManager.py index cff44f583..2e82ee8ad 100644 --- a/plogical/backupManager.py +++ b/plogical/backupManager.py @@ -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) diff --git a/plogical/backupSchedule.py b/plogical/backupSchedule.py index eb8b3a482..8cfa5f07d 100755 --- a/plogical/backupSchedule.py +++ b/plogical/backupSchedule.py @@ -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(): diff --git a/plogical/backupScheduleLocal.py b/plogical/backupScheduleLocal.py index 7129b9867..5cc924e03 100755 --- a/plogical/backupScheduleLocal.py +++ b/plogical/backupScheduleLocal.py @@ -50,7 +50,7 @@ class backupScheduleLocal: writeToFile.close() - except BaseException,msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [214:startBackup]") def main(): diff --git a/plogical/backupUtilities.py b/plogical/backupUtilities.py index b1132eac0..7c73c7830 100755 --- a/plogical/backupUtilities.py +++ b/plogical/backupUtilities.py @@ -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(): diff --git a/plogical/cPanelImporter.py b/plogical/cPanelImporter.py index 5c75c1493..36dafc5b4 100644 --- a/plogical/cPanelImporter.py +++ b/plogical/cPanelImporter.py @@ -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) diff --git a/plogical/cronUtil.py b/plogical/cronUtil.py index 48d45d4c0..f80d64d1f 100755 --- a/plogical/cronUtil.py +++ b/plogical/cronUtil.py @@ -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): diff --git a/plogical/csf.py b/plogical/csf.py index eaafddd24..2c4049fed 100755 --- a/plogical/csf.py +++ b/plogical/csf.py @@ -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]") diff --git a/plogical/dnsUtilities.py b/plogical/dnsUtilities.py index a3fbb1d8f..ae4b973fe 100755 --- a/plogical/dnsUtilities.py +++ b/plogical/dnsUtilities.py @@ -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 diff --git a/plogical/filemanager.py b/plogical/filemanager.py index 69faec37a..70745cacb 100755 --- a/plogical/filemanager.py +++ b/plogical/filemanager.py @@ -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(): diff --git a/plogical/findBWUsage.py b/plogical/findBWUsage.py index 1a88816fe..f62d65f6d 100755 --- a/plogical/findBWUsage.py +++ b/plogical/findBWUsage.py @@ -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 diff --git a/plogical/firewallUtilities.py b/plogical/firewallUtilities.py index a7db987fe..3ac547595 100755 --- a/plogical/firewallUtilities.py +++ b/plogical/firewallUtilities.py @@ -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(): diff --git a/plogical/ftpUtilities.py b/plogical/ftpUtilities.py index 31dab10a3..5703ad5d9 100755 --- a/plogical/ftpUtilities.py +++ b/plogical/ftpUtilities.py @@ -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 diff --git a/plogical/httpProc.py b/plogical/httpProc.py index 2a338664f..61518e85c 100755 --- a/plogical/httpProc.py +++ b/plogical/httpProc.py @@ -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) diff --git a/plogical/installUtilities.py b/plogical/installUtilities.py index cedfbf654..0ef088732 100755 --- a/plogical/installUtilities.py +++ b/plogical/installUtilities.py @@ -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]") diff --git a/plogical/mailUtilities.py b/plogical/mailUtilities.py index 9f99fbbde..1487cc301 100755 --- a/plogical/mailUtilities.py +++ b/plogical/mailUtilities.py @@ -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(): diff --git a/plogical/modSec.py b/plogical/modSec.py index 971fb6a6e..fe6cc9afe 100755 --- a/plogical/modSec.py +++ b/plogical/modSec.py @@ -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(): diff --git a/plogical/mysqlUtilities.py b/plogical/mysqlUtilities.py index 108804a73..47f5e7e9f 100755 --- a/plogical/mysqlUtilities.py +++ b/plogical/mysqlUtilities.py @@ -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 \ No newline at end of file diff --git a/plogical/phpUtilities.py b/plogical/phpUtilities.py index 7a3209bbf..2aa0ef6af 100755 --- a/plogical/phpUtilities.py +++ b/plogical/phpUtilities.py @@ -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)) diff --git a/plogical/processUtilities.py b/plogical/processUtilities.py index c3061bb6a..4fd265e55 100755 --- a/plogical/processUtilities.py +++ b/plogical/processUtilities.py @@ -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 diff --git a/plogical/randomPassword.py b/plogical/randomPassword.py index 2eb292e45..699ad3963 100755 --- a/plogical/randomPassword.py +++ b/plogical/randomPassword.py @@ -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]): diff --git a/plogical/remoteBackup.py b/plogical/remoteBackup.py index 0713f5e8c..02b99589e 100755 --- a/plogical/remoteBackup.py +++ b/plogical/remoteBackup.py @@ -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] diff --git a/plogical/remoteTransferUtilities.py b/plogical/remoteTransferUtilities.py index 6d537a83e..6b566303a 100755 --- a/plogical/remoteTransferUtilities.py +++ b/plogical/remoteTransferUtilities.py @@ -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]") diff --git a/plogical/renew.py b/plogical/renew.py index 08709fc7a..1927a0014 100644 --- a/plogical/renew.py +++ b/plogical/renew.py @@ -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') diff --git a/plogical/serverLogs.py b/plogical/serverLogs.py index 9369d94a4..2788db484 100755 --- a/plogical/serverLogs.py +++ b/plogical/serverLogs.py @@ -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(): diff --git a/plogical/sslUtilities.py b/plogical/sslUtilities.py index 0d6f6cae9..b86332770 100755 --- a/plogical/sslUtilities.py +++ b/plogical/sslUtilities.py @@ -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]"] diff --git a/plogical/tuning.py b/plogical/tuning.py index 5694149fb..1f3919510 100755 --- a/plogical/tuning.py +++ b/plogical/tuning.py @@ -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(): diff --git a/plogical/upgrade.py b/plogical/upgrade.py index e4db365ff..b1fdfcad3 100755 --- a/plogical/upgrade.py +++ b/plogical/upgrade.py @@ -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) diff --git a/plogical/upgradeCritical.py b/plogical/upgradeCritical.py index 8a1fded6b..d6de6a612 100755 --- a/plogical/upgradeCritical.py +++ b/plogical/upgradeCritical.py @@ -16,7 +16,7 @@ class UpgradeCritical: return 1 else: return 0 - except BaseException, msg: + except BaseException as msg: return 0 @staticmethod diff --git a/plogical/vhost.py b/plogical/vhost.py index 148cd2596..2051b5fef 100755 --- a/plogical/vhost.py +++ b/plogical/vhost.py @@ -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]]"] diff --git a/plogical/virtualHostUtilities.py b/plogical/virtualHostUtilities.py index 1cd433c3d..25d156e98 100755 --- a/plogical/virtualHostUtilities.py +++ b/plogical/virtualHostUtilities.py @@ -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)) diff --git a/plogical/website.py b/plogical/website.py index 1bf7aef67..92850923b 100755 --- a/plogical/website.py +++ b/plogical/website.py @@ -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) diff --git a/pluginHolder/admin.py b/pluginHolder/admin.py index 13be29d96..4c33e0ec3 100755 --- a/pluginHolder/admin.py +++ b/pluginHolder/admin.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.contrib import admin diff --git a/pluginHolder/apps.py b/pluginHolder/apps.py index 0d4db0b89..bafa6ab19 100755 --- a/pluginHolder/apps.py +++ b/pluginHolder/apps.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.apps import AppConfig diff --git a/pluginHolder/models.py b/pluginHolder/models.py index 1dfab7604..4e6a8e76d 100755 --- a/pluginHolder/models.py +++ b/pluginHolder/models.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models diff --git a/pluginHolder/tests.py b/pluginHolder/tests.py index 5982e6bcd..f067dcaac 100755 --- a/pluginHolder/tests.py +++ b/pluginHolder/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.test import TestCase diff --git a/pluginHolder/views.py b/pluginHolder/views.py index 859d48216..44e564fc3 100755 --- a/pluginHolder/views.py +++ b/pluginHolder/views.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.shortcuts import render from plogical.mailUtilities import mailUtilities diff --git a/pluginInstaller/pluginInstaller.py b/pluginInstaller/pluginInstaller.py index e79437ac5..fea02aceb 100755 --- a/pluginInstaller/pluginInstaller.py +++ b/pluginInstaller/pluginInstaller.py @@ -16,11 +16,11 @@ class pluginInstaller: @staticmethod def stdOut(message): 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")) ### Functions Related to plugin installation. @@ -186,7 +186,7 @@ class pluginInstaller: pluginInstaller.stdOut('Plugin successfully installed.') - except BaseException, msg: + except BaseException as msg: pluginInstaller.stdOut(str(msg)) ### Functions Related to plugin installation. @@ -280,7 +280,7 @@ class pluginInstaller: pluginInstaller.stdOut('Plugin successfully removed.') - except BaseException, msg: + except BaseException as msg: pluginInstaller.stdOut(str(msg)) #### diff --git a/postfixSenderPolicy/accept_traffic.py b/postfixSenderPolicy/accept_traffic.py index 54aec3c94..d4502b789 100755 --- a/postfixSenderPolicy/accept_traffic.py +++ b/postfixSenderPolicy/accept_traffic.py @@ -23,7 +23,7 @@ class HandleRequest(multi.Thread): def __del__(self): try: self.connection.close() - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + ' [HandleRequest.__del__]') def run(self): @@ -62,7 +62,7 @@ class HandleRequest(multi.Thread): self.connection.close() break - except BaseException, msg: + except BaseException as msg: logging.writeToFile( str(msg) + ' [HandleRequest.run]') finally: limitThreads.release() @@ -136,6 +136,6 @@ class HandleRequest(multi.Thread): self.connection.sendall('action=dunno\n\n') - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + " [HandleRequest.manageRequest]") self.connection.sendall('action=defer_if_permit Service temporarily unavailable\n\n') diff --git a/postfixSenderPolicy/cacheManager.py b/postfixSenderPolicy/cacheManager.py index 0bf33aa11..3376dab2f 100755 --- a/postfixSenderPolicy/cacheManager.py +++ b/postfixSenderPolicy/cacheManager.py @@ -15,14 +15,14 @@ class cacheManager: def flushCache(): try: - for domain, domainOBJ in cacheManager.domains.iteritems(): + for domain, domainOBJ in cacheManager.domains.items(): domaindb = Domains.objects.get(domain=domain) dbDomain = DomainLimits.objects.get(domain=domaindb) dbDomain.monthlyUsed = domainOBJ.monthlyUsed dbDomain.save() - for email, emailOBJ in domainOBJ.emails.iteritems(): + for email, emailOBJ in domainOBJ.emails.items(): emailID = EUsers.objects.get(email=email) dbEmail = EmailLimits.objects.get(email=emailID) @@ -30,7 +30,7 @@ class cacheManager: dbEmail.hourlyUsed = emailOBJ.hourlyUsed dbEmail.save() - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + ' [cacheManager.flushCache]') @staticmethod @@ -44,7 +44,7 @@ class cacheManager: emailOBJ = domainOBJ.emails[emailAddress] emailOBJ.logStatus = operationValue - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + ' [cacheManager.disableEnableLogs]') @staticmethod @@ -59,7 +59,7 @@ class cacheManager: emailOBJ = domainOBJ.emails[email] emailOBJ.logStatus = operationVal - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + ' [cacheManager.purgeLog]') @staticmethod @@ -74,7 +74,7 @@ class cacheManager: emailOBJ = domainOBJ.emails[email] emailOBJ.limitStatus = operationVal - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + ' [cacheManager.purgeLimit]') @staticmethod @@ -87,7 +87,7 @@ class cacheManager: domainOBJ = cacheManager.domains[domain] domainOBJ.limitStatus = operationVal - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + ' [cacheManager.purgeLimitDomain]') @staticmethod @@ -100,7 +100,7 @@ class cacheManager: domainOBJ = cacheManager.domains[domain] domainOBJ.monthlyLimits = newLimit - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + ' [cacheManager.updateDomainLimit]') @staticmethod @@ -117,14 +117,14 @@ class cacheManager: emailOBJ.monthlyLimits = monthlyLimit emailOBJ.hourlyLimits = hourlyLimit - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + ' [cacheManager.purgeLimitEmail]') @staticmethod def hourlyCleanUP(): try: - for domain, domainOBJ in cacheManager.domains.iteritems(): - for email, emailOBJ in domainOBJ.emails.iteritems(): + for domain, domainOBJ in cacheManager.domains.items(): + for email, emailOBJ in domainOBJ.emails.items(): emailID = EUsers.objects.get(email=email) dbEmail = EmailLimits.objects.get(email=emailID) @@ -135,19 +135,19 @@ class cacheManager: dbEmail.hourlyUsed = 0 emailOBJ.hourlyUsed = 0 - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + ' [cacheManager.hourlyCleanUP]') @staticmethod def monthlyCleanUP(): try: - for domain, domainOBJ in cacheManager.domains.iteritems(): + for domain, domainOBJ in cacheManager.domains.items(): domaindb = Domains.objects.get(domain=domain) dbDomain = DomainLimits.objects.get(domain=domaindb) - for email, emailOBJ in domainOBJ.emails.iteritems(): + for email, emailOBJ in domainOBJ.emails.items(): emailID = EUsers.objects.get(email=email) dbEmail = EmailLimits.objects.get(email=emailID) @@ -160,7 +160,7 @@ class cacheManager: dbDomain.monthlyUsed = 0 dbDomain.save() - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + ' [cacheManager.monthlyCleanUP]') @@ -191,6 +191,6 @@ class cacheManager: cacheManager.monthlyCleanUP() - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + ' [cacheManager.handlePurgeRequest]') diff --git a/postfixSenderPolicy/client.py b/postfixSenderPolicy/client.py index 40599be6f..e5d224196 100755 --- a/postfixSenderPolicy/client.py +++ b/postfixSenderPolicy/client.py @@ -17,7 +17,7 @@ class cacheClient: writeToFile.write(command) writeToFile.close() - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + ' [cacheClient.handleCachePurgeRequest]') diff --git a/postfixSenderPolicy/policyCTRL.py b/postfixSenderPolicy/policyCTRL.py index a7a29a6b4..63c916353 100755 --- a/postfixSenderPolicy/policyCTRL.py +++ b/postfixSenderPolicy/policyCTRL.py @@ -34,7 +34,7 @@ class policyCTRL: pid = open(path, "r").readlines()[0] try: os.kill(int(pid), signal.SIGTERM) - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg)) diff --git a/postfixSenderPolicy/startServer.py b/postfixSenderPolicy/startServer.py index ab68fb6ca..09983402e 100755 --- a/postfixSenderPolicy/startServer.py +++ b/postfixSenderPolicy/startServer.py @@ -39,10 +39,10 @@ class SetupConn: uid = pwd.getpwnam("postfix").pw_uid gid = grp.getgrnam("postfix").gr_gid os.chown(self.server_addr, uid, gid) - os.chmod(self.server_addr, 0755) + os.chmod(self.server_addr, 0o755) logging.writeToFile('CyberPanel Email Policy Server Successfully started!') - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + ' [SetupConn.setup_conn]') def start_listening(self): @@ -63,7 +63,7 @@ class SetupConn: connection, client_address = self.sock.accept() background = handle.HandleRequest(connection) background.start() - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + ' [SetupConn.start_listening]') def __del__(self): diff --git a/s3Backups/admin.py b/s3Backups/admin.py index 13be29d96..4c33e0ec3 100755 --- a/s3Backups/admin.py +++ b/s3Backups/admin.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.contrib import admin diff --git a/s3Backups/apps.py b/s3Backups/apps.py index 1a31291f0..586d1928a 100755 --- a/s3Backups/apps.py +++ b/s3Backups/apps.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.apps import AppConfig diff --git a/s3Backups/models.py b/s3Backups/models.py index d57aa8af9..be1e7cdff 100755 --- a/s3Backups/models.py +++ b/s3Backups/models.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models from loginSystem.models import Administrator diff --git a/s3Backups/s3Backups.py b/s3Backups/s3Backups.py index 6d8aa8f82..20909529d 100755 --- a/s3Backups/s3Backups.py +++ b/s3Backups/s3Backups.py @@ -50,7 +50,7 @@ class S3Backups(multi.Thread): self.runAWSBackups() elif self.function == 'forceRunAWSBackupMINIO': self.forceRunAWSBackupMINIO() - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + ' [S3Backups.run]') @staticmethod @@ -131,7 +131,7 @@ class S3Backups(multi.Thread): os.remove(tempPath) except: pass - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + " [S3Backups.setupCron]") def connectAccount(self): @@ -164,7 +164,7 @@ class S3Backups(multi.Thread): return proc.ajax(1, None) - except BaseException, msg: + except BaseException as msg: proc = httpProc(self.request, None, None) return proc.ajax(0, str(msg)) @@ -215,7 +215,7 @@ class S3Backups(multi.Thread): final_json = json.dumps({'status': 1, 'error_message': "None", "data": json_data}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: proc = httpProc(self.request, None, None) return proc.ajax(0, str(msg)) @@ -242,7 +242,7 @@ class S3Backups(multi.Thread): return proc.ajax(1, None) - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + ' [createPlan]') proc = httpProc(self.request, None, None) return proc.ajax(0, str(msg)) @@ -281,7 +281,7 @@ class S3Backups(multi.Thread): final_json = json.dumps({'status': 1, 'error_message': "None", "data": json_data}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: proc = httpProc(self.request, None, None) return proc.ajax(0, str(msg)) @@ -301,7 +301,7 @@ class S3Backups(multi.Thread): return proc.ajax(1, None) - except BaseException, msg: + except BaseException as msg: proc = httpProc(self.request, None, None) return proc.ajax(0, str(msg)) @@ -336,7 +336,7 @@ class S3Backups(multi.Thread): final_json = json.dumps({'status': 1, 'error_message': "None", "data": json_data}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: proc = httpProc(self.request, None, None) return proc.ajax(0, str(msg)) @@ -357,7 +357,7 @@ class S3Backups(multi.Thread): return proc.ajax(1, None) - except BaseException, msg: + except BaseException as msg: proc = httpProc(self.request, None, None) return proc.ajax(0, str(msg)) @@ -382,7 +382,7 @@ class S3Backups(multi.Thread): return proc.ajax(1, None) - except BaseException, msg: + except BaseException as msg: proc = httpProc(self.request, None, None) return proc.ajax(0, str(msg)) @@ -412,7 +412,7 @@ class S3Backups(multi.Thread): return proc.ajax(1, None, data) - except BaseException, msg: + except BaseException as msg: proc = httpProc(self.request, None, None) return proc.ajaxPre(0, str(msg)) @@ -516,7 +516,7 @@ class S3Backups(multi.Thread): ] } ) - except BaseException, msg: + except BaseException as msg: BackupLogs(owner=plan, timeStamp=time.strftime("%b %d %Y, %H:%M:%S"), level='ERROR', msg=str(msg)).save() @@ -558,7 +558,7 @@ class S3Backups(multi.Thread): BackupLogs(owner=plan, level='INFO', timeStamp=time.strftime("%b %d %Y, %H:%M:%S"), msg='Backup Process Finished.').save() - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + ' [S3Backups.runBackupPlan]') plan = BackupPlan.objects.get(name=self.data['planName']) BackupLogs(owner=plan, timeStamp=time.strftime("%b %d %Y, %H:%M:%S"), level='ERROR', msg=str(msg)).save() @@ -593,7 +593,7 @@ class S3Backups(multi.Thread): return proc.ajax(1, None) - except BaseException, msg: + except BaseException as msg: proc = httpProc(self.request, None, None) return proc.ajax(0, str(msg)) @@ -641,7 +641,7 @@ class S3Backups(multi.Thread): final_json = json.dumps({'status': 1, 'error_message': "None", "data": json_data}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg)) proc = httpProc(self.request, None, None) return proc.ajax(0, str(msg)) @@ -672,7 +672,7 @@ class S3Backups(multi.Thread): return proc.ajax(1, None) - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + ' [createPlanDO]') proc = httpProc(self.request, None, None) return proc.ajax(0, str(msg)) @@ -711,7 +711,7 @@ class S3Backups(multi.Thread): final_json = json.dumps({'status': 1, 'error_message': "None", "data": json_data}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: proc = httpProc(self.request, None, None) return proc.ajax(0, str(msg)) @@ -731,7 +731,7 @@ class S3Backups(multi.Thread): return proc.ajax(1, None) - except BaseException, msg: + except BaseException as msg: proc = httpProc(self.request, None, None) return proc.ajax(0, str(msg)) @@ -766,7 +766,7 @@ class S3Backups(multi.Thread): final_json = json.dumps({'status': 1, 'error_message': "None", "data": json_data}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: proc = httpProc(self.request, None, None) return proc.ajax(0, str(msg)) @@ -796,7 +796,7 @@ class S3Backups(multi.Thread): return proc.ajax(1, None, data) - except BaseException, msg: + except BaseException as msg: proc = httpProc(self.request, None, None) return proc.ajaxPre(0, str(msg)) @@ -817,7 +817,7 @@ class S3Backups(multi.Thread): return proc.ajax(1, None) - except BaseException, msg: + except BaseException as msg: proc = httpProc(self.request, None, None) return proc.ajax(0, str(msg)) @@ -843,7 +843,7 @@ class S3Backups(multi.Thread): return proc.ajax(1, None) - except BaseException, msg: + except BaseException as msg: proc = httpProc(self.request, None, None) return proc.ajax(0, str(msg)) @@ -898,7 +898,7 @@ class S3Backups(multi.Thread): ] } ) - except BaseException, msg: + except BaseException as msg: BackupLogsDO(owner=plan, timeStamp=time.strftime("%b %d %Y, %H:%M:%S"), level='ERROR', msg=str(msg)).save() @@ -939,7 +939,7 @@ class S3Backups(multi.Thread): BackupLogsDO(owner=plan, level='INFO', timeStamp=time.strftime("%b %d %Y, %H:%M:%S"), msg='Backup Process Finished.').save() - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + ' [S3Backups.forceRunAWSBackupDO]') plan = BackupPlanDO.objects.get(name=self.data['planName']) BackupLogsDO(owner=plan, timeStamp=time.strftime("%b %d %Y, %H:%M:%S"), level='ERROR', msg=str(msg)).save() @@ -965,7 +965,7 @@ class S3Backups(multi.Thread): return proc.ajax(1, None) - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + ' [addMINIONode]') proc = httpProc(self.request, None, None) return proc.ajax(0, str(msg)) @@ -1001,7 +1001,7 @@ class S3Backups(multi.Thread): final_json = json.dumps({'status': 1, 'error_message': "None", "data": json_data}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: proc = httpProc(self.request, None, None) return proc.ajax(0, str(msg)) @@ -1021,7 +1021,7 @@ class S3Backups(multi.Thread): return proc.ajax(1, None) - except BaseException, msg: + except BaseException as msg: proc = httpProc(self.request, None, None) return proc.ajax(0, str(msg)) @@ -1051,7 +1051,7 @@ class S3Backups(multi.Thread): return proc.ajax(1, None) - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + ' [createPlanDO]') proc = httpProc(self.request, None, None) return proc.ajax(0, str(msg)) @@ -1090,7 +1090,7 @@ class S3Backups(multi.Thread): final_json = json.dumps({'status': 1, 'error_message': "None", "data": json_data}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: proc = httpProc(self.request, None, None) return proc.ajax(0, str(msg)) @@ -1110,7 +1110,7 @@ class S3Backups(multi.Thread): return proc.ajax(1, None) - except BaseException, msg: + except BaseException as msg: proc = httpProc(self.request, None, None) return proc.ajax(0, str(msg)) @@ -1136,7 +1136,7 @@ class S3Backups(multi.Thread): return proc.ajax(1, None) - except BaseException, msg: + except BaseException as msg: proc = httpProc(self.request, None, None) return proc.ajax(0, str(msg)) @@ -1166,7 +1166,7 @@ class S3Backups(multi.Thread): try: client.create_bucket(Bucket=plan.name.lower()) - except BaseException, msg: + except BaseException as msg: BackupLogsMINIO(owner=plan, level='INFO', timeStamp=time.strftime("%b %d %Y, %H:%M:%S"), msg=str(msg)).save() return 0 @@ -1208,7 +1208,7 @@ class S3Backups(multi.Thread): BackupLogsMINIO(owner=plan, level='INFO', timeStamp=time.strftime("%b %d %Y, %H:%M:%S"), msg='Backup Process Finished.').save() - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + ' [S3Backups.forceRunAWSBackupMINIO]') plan = BackupPlanMINIO.objects.get(name=self.data['planName']) BackupLogsMINIO(owner=plan, timeStamp=time.strftime("%b %d %Y, %H:%M:%S"), level='ERROR', @@ -1245,7 +1245,7 @@ class S3Backups(multi.Thread): final_json = json.dumps({'status': 1, 'error_message': "None", "data": json_data}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: proc = httpProc(self.request, None, None) return proc.ajax(0, str(msg)) @@ -1275,7 +1275,7 @@ class S3Backups(multi.Thread): return proc.ajax(1, None, data) - except BaseException, msg: + except BaseException as msg: proc = httpProc(self.request, None, None) return proc.ajaxPre(0, str(msg)) @@ -1296,7 +1296,7 @@ class S3Backups(multi.Thread): return proc.ajax(1, None) - except BaseException, msg: + except BaseException as msg: proc = httpProc(self.request, None, None) return proc.ajax(0, str(msg)) @@ -1374,7 +1374,7 @@ class S3Backups(multi.Thread): self.data['planName'] = plan.name self.forceRunAWSBackupMINIO() - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + ' [S3Backups.runAWSBackups]') diff --git a/s3Backups/tests.py b/s3Backups/tests.py index 5982e6bcd..f067dcaac 100755 --- a/s3Backups/tests.py +++ b/s3Backups/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.test import TestCase diff --git a/s3Backups/views.py b/s3Backups/views.py index e784a0bd2..e2a525da4 100755 --- a/s3Backups/views.py +++ b/s3Backups/views.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.shortcuts import render diff --git a/serverLogs/admin.py b/serverLogs/admin.py index 13be29d96..4c33e0ec3 100755 --- a/serverLogs/admin.py +++ b/serverLogs/admin.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.contrib import admin diff --git a/serverLogs/apps.py b/serverLogs/apps.py index 3ff38b65d..80dfd1263 100755 --- a/serverLogs/apps.py +++ b/serverLogs/apps.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.apps import AppConfig diff --git a/serverLogs/models.py b/serverLogs/models.py index 1dfab7604..4e6a8e76d 100755 --- a/serverLogs/models.py +++ b/serverLogs/models.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models diff --git a/serverLogs/tests.py b/serverLogs/tests.py index 5982e6bcd..f067dcaac 100755 --- a/serverLogs/tests.py +++ b/serverLogs/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.test import TestCase diff --git a/serverLogs/views.py b/serverLogs/views.py index 300509a09..cfa233fe8 100755 --- a/serverLogs/views.py +++ b/serverLogs/views.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.shortcuts import render,redirect from loginSystem.views import loadLoginPage @@ -43,7 +43,7 @@ def accessLogs(request): return render(request,'serverLogs/accessLogs.html') - except KeyError,msg: + except KeyError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[accessLogs]") return redirect(loadLoginPage) @@ -60,7 +60,7 @@ def errorLogs(request): return render(request,'serverLogs/errorLogs.html') - except KeyError,msg: + except KeyError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[accessLogs]") return redirect(loadLoginPage) @@ -76,7 +76,7 @@ def ftplogs(request): return render(request,'serverLogs/ftplogs.html') - except KeyError,msg: + except KeyError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[accessLogs]") return redirect(loadLoginPage) @@ -93,7 +93,7 @@ def emailLogs(request): return render(request,'serverLogs/emailLogs.html') - except KeyError,msg: + except KeyError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[accessLogs]") return redirect(loadLoginPage) @@ -109,7 +109,7 @@ def modSecAuditLogs(request): return render(request,'serverLogs/modSecAuditLog.html') - except KeyError,msg: + except KeyError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[accessLogs]") return redirect(loadLoginPage) @@ -156,7 +156,7 @@ def getLogsFromFile(request): final_json = json.dumps(status) return HttpResponse(final_json) - except KeyError, msg: + except KeyError as msg: status = {"status": 0, "logstatus":0,"error":"Could not fetch data from log file, please see CyberCP main log file through command line."} logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[getLogsFromFile]") final_json = json.dumps(status) @@ -193,12 +193,12 @@ def clearLogFile(request): json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException,msg: + except BaseException as msg: data_ret = {'cleanStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) - except KeyError,msg: + except KeyError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) data_ret = {'cleanStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) diff --git a/serverStatus/admin.py b/serverStatus/admin.py index 13be29d96..4c33e0ec3 100755 --- a/serverStatus/admin.py +++ b/serverStatus/admin.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.contrib import admin diff --git a/serverStatus/apps.py b/serverStatus/apps.py index 49b7aa0b7..207a93608 100755 --- a/serverStatus/apps.py +++ b/serverStatus/apps.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.apps import AppConfig diff --git a/serverStatus/models.py b/serverStatus/models.py index 1dfab7604..4e6a8e76d 100755 --- a/serverStatus/models.py +++ b/serverStatus/models.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models diff --git a/serverStatus/serverStatusUtil.py b/serverStatus/serverStatusUtil.py index 3014ccc5d..9a4b72050 100755 --- a/serverStatus/serverStatusUtil.py +++ b/serverStatus/serverStatusUtil.py @@ -29,7 +29,7 @@ class ServerStatusUtil: return 0 else: return 1 - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) return 0 @@ -124,7 +124,7 @@ class ServerStatusUtil: return 1 - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) return 0 @@ -147,7 +147,7 @@ class ServerStatusUtil: logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,"Filemanager files are set!\n") return 1 - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) return 0 @@ -196,7 +196,7 @@ class ServerStatusUtil: cmd = shlex.split(command) subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) return 0 @@ -233,7 +233,7 @@ class ServerStatusUtil: cmd = shlex.split(command) subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) return 0 @@ -254,7 +254,7 @@ class ServerStatusUtil: if ServerStatusUtil.createDomain(child) == 0: logging.CyberCPLogFileWriter.writeToFile( 'Error while creating child domain: ' + child.domain) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( 'Error while creating child domain: ' + child.domain + ' . Exact message: ' + str( msg)) @@ -266,14 +266,14 @@ class ServerStatusUtil: aliasDomain = alias.aliasDomain alias.delete() virtualHostUtilities.createAlias(website.domain, aliasDomain, 0, '/home', website.adminEmail, website.admin) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( 'Error while creating alais domain: ' + aliasDomain + ' . Exact message: ' + str( msg)) logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, "vhost conf successfully built for: " + website.domain + ".\n", 1) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) return 0 @@ -351,7 +351,7 @@ class ServerStatusUtil: logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,"Successfully switched to LITESPEED ENTERPRISE WEB SERVER. [200]\n", 1) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, "%s. [404]" % (str(msg)), 1) logging.CyberCPLogFileWriter.writeToFile(str(msg)) diff --git a/serverStatus/tests.py b/serverStatus/tests.py index 5982e6bcd..f067dcaac 100755 --- a/serverStatus/tests.py +++ b/serverStatus/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.test import TestCase diff --git a/serverStatus/views.py b/serverStatus/views.py index 2b3e16e61..217a366a6 100755 --- a/serverStatus/views.py +++ b/serverStatus/views.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.shortcuts import render, redirect from django.http import HttpResponse @@ -75,7 +75,7 @@ def litespeedStatus(request): else: loadedModules.append(items) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[litespeedStatus]") return render(request, "serverStatus/litespeedStatus.html", {"processList": processList, "liteSpeedVersionStatus": "For some reaons not able to load version details, see CyberCP main log file.", @@ -89,7 +89,7 @@ def litespeedStatus(request): "loadedModules": loadedModules, 'OLS': OLS, 'message': message} return render(request, "serverStatus/litespeedStatus.html", dataForHtml) - except KeyError, msg: + except KeyError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[litespeedStatus]") return redirect(loadLoginPage) @@ -123,7 +123,7 @@ def stopOrRestartLitespeed(request): final_json = json.dumps(status) return HttpResponse(final_json) - except KeyError, msg: + except KeyError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[stopOrRestartLitespeed]") return HttpResponse("Not Logged in as admin") @@ -141,7 +141,7 @@ def cyberCPMainLogFile(request): return render(request, 'serverStatus/cybercpmainlogfile.html') - except KeyError, msg: + except KeyError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[cyberCPMainLogFile]") return redirect(loadLoginPage) @@ -163,7 +163,7 @@ def getFurtherDataFromLogFile(request): final_json = json.dumps(status) return HttpResponse(final_json) - except KeyError, msg: + except KeyError as msg: status = {"logstatus": 0, "error": "Could not fetch data from log file, please see CyberCP main log file through command line."} logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[getFurtherDataFromLogFile]") @@ -335,11 +335,11 @@ def servicesAction(request): return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'serviceAction': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) - except KeyError, msg: + except KeyError as msg: final_dic = {'serviceAction': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -373,7 +373,7 @@ def switchTOLSWS(request): json_data = json.dumps(data_ret) 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) @@ -402,7 +402,7 @@ def switchTOLSWSStatus(request): json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: command = "sudo rm -f " + serverStatusUtil.ServerStatusUtil.lswsInstallStatusPath ProcessUtilities.popenExecutioner(command) data_ret = {'status': 0,'abort': 1, 'requestStatus': str(msg), 'installed': 0} @@ -431,11 +431,11 @@ def licenseStatus(request): final_json = json.dumps(final_dic) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'erroMessage': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) - except KeyError, msg: + except KeyError as msg: final_dic = {'status': 0, 'erroMessage': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -477,11 +477,11 @@ def changeLicense(request): final_json = json.dumps(final_dic) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'erroMessage': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) - except KeyError, msg: + except KeyError as msg: final_dic = {'status': 0, 'erroMessage': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -501,7 +501,7 @@ def topProcesses(request): proc = httpProc(request, templateName) return proc.renderPre() - except KeyError, msg: + except KeyError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[litespeedStatus]") return redirect(loadLoginPage) @@ -526,19 +526,19 @@ def topProcessesStatus(request): counter = 0 loadAVG = data[0].split(' ') - loadAVG = filter(lambda a: a != '', loadAVG) + loadAVG = [a for a in loadAVG if a != ''] loadNow = data[2].split(' ') - loadNow = filter(lambda a: a != '', loadNow) + loadNow = [a for a in loadNow if a != ''] memory = data[3].split(' ') - memory = filter(lambda a: a != '', memory) + memory = [a for a in memory if a != ''] swap = data[4].split(' ') - swap = filter(lambda a: a != '', swap) + swap = [a for a in swap if a != ''] processes = data[1].split(' ') - processes = filter(lambda a: a != '', processes) + processes = [a for a in processes if a != ''] for items in data: counter = counter + 1 @@ -546,7 +546,7 @@ def topProcessesStatus(request): continue points = items.split(' ') - points = filter(lambda a: a != '', points) + points = [a for a in points if a != ''] dic = {'PID': points[0], 'User': points[1], 'VIRT': points[4], 'RES': points[5], 'S': points[7], 'CPU': points[8], 'MEM': points[9], @@ -623,7 +623,7 @@ def topProcessesStatus(request): final_json = json.dumps(data) return HttpResponse(final_json) - 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) @@ -649,11 +649,11 @@ def killProcess(request): proc = httpProc(request, None) return proc.ajax(1, None) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'erroMessage': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) - except KeyError, msg: + except KeyError as msg: final_dic = {'status': 0, 'erroMessage': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) \ No newline at end of file diff --git a/tuning/admin.py b/tuning/admin.py index 13be29d96..4c33e0ec3 100755 --- a/tuning/admin.py +++ b/tuning/admin.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.contrib import admin diff --git a/tuning/apps.py b/tuning/apps.py index 01041a7b2..5ecd5d5ed 100755 --- a/tuning/apps.py +++ b/tuning/apps.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.apps import AppConfig diff --git a/tuning/models.py b/tuning/models.py index 1dfab7604..4e6a8e76d 100755 --- a/tuning/models.py +++ b/tuning/models.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models diff --git a/tuning/tests.py b/tuning/tests.py index 5982e6bcd..f067dcaac 100755 --- a/tuning/tests.py +++ b/tuning/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.test import TestCase diff --git a/tuning/tuning.py b/tuning/tuning.py index 66776372f..f36fe3499 100755 --- a/tuning/tuning.py +++ b/tuning/tuning.py @@ -137,7 +137,7 @@ class tuningManager: final_json = json.dumps(data_ret) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: data_ret = {'fetch_status': 0, 'error_message': str(msg), 'tuneStatus': 0} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -190,7 +190,7 @@ class tuningManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'fetch_status': 0, 'error_message': str(msg), 'tuneStatus': 0} logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [tunePHP]]") json_data = json.dumps(data_ret) diff --git a/tuning/views.py b/tuning/views.py index 215047ba3..eee9dfbd5 100755 --- a/tuning/views.py +++ b/tuning/views.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.shortcuts import redirect import json diff --git a/userManagment/admin.py b/userManagment/admin.py index 13be29d96..4c33e0ec3 100755 --- a/userManagment/admin.py +++ b/userManagment/admin.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.contrib import admin diff --git a/userManagment/apps.py b/userManagment/apps.py index a4cc35103..b023ad107 100755 --- a/userManagment/apps.py +++ b/userManagment/apps.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.apps import AppConfig diff --git a/userManagment/models.py b/userManagment/models.py index 1dfab7604..4e6a8e76d 100755 --- a/userManagment/models.py +++ b/userManagment/models.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models diff --git a/userManagment/tests.py b/userManagment/tests.py index 1092e7897..8b214fad1 100755 --- a/userManagment/tests.py +++ b/userManagment/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.test import TestCase, Client from django.urls import reverse diff --git a/userManagment/views.py b/userManagment/views.py index 86b20a05d..a43049599 100755 --- a/userManagment/views.py +++ b/userManagment/views.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.shortcuts import render, redirect from django.http import HttpResponse @@ -25,7 +25,7 @@ def loadUserHome(request): else: listUsers = currentACL['listUsers'] return render(request, 'userManagment/index.html', {"type": admin.type, 'listUsers': listUsers}) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) return HttpResponse(str(msg)) @@ -70,7 +70,7 @@ def createUser(request): else: return ACLManager.loadError() - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) return redirect(loadLoginPage) @@ -87,7 +87,7 @@ def apiAccess(request): else: return ACLManager.loadError() - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) return redirect(loadLoginPage) @@ -118,7 +118,7 @@ def saveChangesAPIAccess(request): finalResponse = {'status': 1} json_data = json.dumps(finalResponse) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: finalResponse = {'status': 0, 'errorMessage': str(msg), 'error_message': str(msg)} json_data = json.dumps(finalResponse) return HttpResponse(json_data) @@ -222,7 +222,7 @@ def submitUserCreation(request): final_json = json.dumps(data_ret) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'createStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -292,7 +292,7 @@ def fetchUserDetails(request): json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'fetchStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -352,7 +352,7 @@ def saveModifications(request): 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) @@ -414,7 +414,7 @@ def submitUserDeletion(request): json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'deleteStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -525,7 +525,7 @@ def createACLFunc(request): json_data = json.dumps(finalResponse) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: finalResponse = {'status': 0, 'errorMessage': str(msg), 'error_message': str(msg)} json_data = json.dumps(finalResponse) return HttpResponse(json_data) @@ -566,7 +566,7 @@ def deleteACLFunc(request): json_data = json.dumps(finalResponse) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: finalResponse = {'status': 0, 'errorMessage': str(msg), 'error_message': str(msg)} json_data = json.dumps(finalResponse) return HttpResponse(json_data) @@ -672,7 +672,7 @@ def fetchACLDetails(request): json_data = json.dumps(finalResponse) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: finalResponse = {'status': 0, 'errorMessage': str(msg)} json_data = json.dumps(finalResponse) return HttpResponse(json_data) @@ -778,7 +778,7 @@ def submitACLModifications(request): json_data = json.dumps(finalResponse) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: finalResponse = {'status': 0, 'errorMessage': str(msg), 'error_message': str(msg)} json_data = json.dumps(finalResponse) return HttpResponse(json_data) @@ -841,7 +841,7 @@ def changeACLFunc(request): json_data = json.dumps(finalResponse) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: finalResponse = {'status': 0, 'errorMessage': str(msg), 'error_message': str(msg)} json_data = json.dumps(finalResponse) return HttpResponse(json_data) @@ -914,7 +914,7 @@ def saveResellerChanges(request): finalResponse = {'status': 1} json_data = json.dumps(finalResponse) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: finalResponse = {'status': 0, 'errorMessage': str(msg), 'error_message': str(msg)} json_data = json.dumps(finalResponse) return HttpResponse(json_data) diff --git a/websiteFunctions/StagingSetup.py b/websiteFunctions/StagingSetup.py index 7693e2fe0..c5dc5335e 100644 --- a/websiteFunctions/StagingSetup.py +++ b/websiteFunctions/StagingSetup.py @@ -23,7 +23,7 @@ class StagingSetup(multi.Thread): self.startCloning() elif self.function == 'startSyncing': self.startSyncing() - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + ' [StagingSetup.run]') def startCloning(self): @@ -160,7 +160,7 @@ class StagingSetup(multi.Thread): logging.statusWriter(tempStatusPath, 'Data copied..,[200]') return 0 - except BaseException, msg: + except BaseException as msg: mesg = '%s. [404]' % (str(msg)) logging.statusWriter(self.tempStatusPath, mesg) @@ -239,6 +239,6 @@ class StagingSetup(multi.Thread): logging.statusWriter(tempStatusPath, 'Data copied..,[200]') return 0 - except BaseException, msg: + except BaseException as msg: mesg = '%s. [404]' % (str(msg)) logging.statusWriter(tempStatusPath, mesg) diff --git a/websiteFunctions/admin.py b/websiteFunctions/admin.py index 81305320b..9f27f8e5b 100755 --- a/websiteFunctions/admin.py +++ b/websiteFunctions/admin.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.contrib import admin import models diff --git a/websiteFunctions/apps.py b/websiteFunctions/apps.py index 38f6437c5..8fc081888 100755 --- a/websiteFunctions/apps.py +++ b/websiteFunctions/apps.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.apps import AppConfig diff --git a/websiteFunctions/models.py b/websiteFunctions/models.py index 5d3476e0a..36958a4a7 100755 --- a/websiteFunctions/models.py +++ b/websiteFunctions/models.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models from packages.models import Package diff --git a/websiteFunctions/tests.py b/websiteFunctions/tests.py index cf67fd790..5bf21bab6 100755 --- a/websiteFunctions/tests.py +++ b/websiteFunctions/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.test import TestCase import json diff --git a/websiteFunctions/views.py b/websiteFunctions/views.py index 0528ee6a7..45a8068fc 100755 --- a/websiteFunctions/views.py +++ b/websiteFunctions/views.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.shortcuts import render,redirect from django.http import HttpResponse @@ -31,7 +31,7 @@ def modifyWebsite(request): userID = request.session['userID'] wm = WebsiteManager() return wm.modifyWebsite(request, userID) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) except KeyError: diff --git a/websiteFunctions/website.py b/websiteFunctions/website.py index 3031c6988..62c309884 100755 --- a/websiteFunctions/website.py +++ b/websiteFunctions/website.py @@ -63,7 +63,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): @@ -78,7 +78,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): @@ -90,7 +90,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): @@ -103,7 +103,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): @@ -112,7 +112,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): @@ -120,7 +120,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): @@ -144,7 +144,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): @@ -213,7 +213,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) @@ -271,7 +271,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) @@ -294,7 +294,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) @@ -304,7 +304,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) @@ -314,7 +314,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) @@ -329,7 +329,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) @@ -350,7 +350,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) @@ -365,7 +365,7 @@ class WebsiteManager: 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" @@ -439,7 +439,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) @@ -464,7 +464,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) @@ -504,7 +504,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) @@ -572,7 +572,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) @@ -624,7 +624,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) @@ -672,7 +672,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) @@ -714,7 +714,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] @@ -765,7 +765,7 @@ class WebsiteManager: else: Data['authority'] = '%s has SSL from %s.' % (self.domain, Data['authority']) - except BaseException, msg: + except BaseException as msg: Data['viewSSL'] = 0 logging.CyberCPLogFileWriter.writeToFile(str(msg)) @@ -816,7 +816,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] @@ -873,7 +873,7 @@ class WebsiteManager: else: Data['authority'] = '%s has SSL from %s.' % (self.childDomain, Data['authority']) - except BaseException, msg: + except BaseException as msg: Data['viewSSL'] = 0 logging.CyberCPLogFileWriter.writeToFile(str(msg)) @@ -1244,7 +1244,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) @@ -1308,8 +1308,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) @@ -1359,7 +1359,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) @@ -1401,7 +1401,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) @@ -1457,7 +1457,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) @@ -1509,7 +1509,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) @@ -1546,7 +1546,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) @@ -1581,7 +1581,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) @@ -1607,7 +1607,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) @@ -1624,7 +1624,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): @@ -1666,7 +1666,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) @@ -1703,7 +1703,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) @@ -1719,7 +1719,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): @@ -1750,7 +1750,7 @@ class WebsiteManager: statusFile = open(tempStatusPath, 'w') statusFile.writelines('Setting up paths,0') statusFile.close() - os.chmod(tempStatusPath, 0777) + os.chmod(tempStatusPath, 0o777) finalPath = "" @@ -1851,7 +1851,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) @@ -1908,7 +1908,7 @@ StrictHostKeyChecking no 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): @@ -1945,7 +1945,7 @@ StrictHostKeyChecking no 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) @@ -1963,7 +1963,7 @@ StrictHostKeyChecking no 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) @@ -1996,7 +1996,7 @@ StrictHostKeyChecking no 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) @@ -2030,7 +2030,7 @@ StrictHostKeyChecking no 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) @@ -2046,7 +2046,7 @@ StrictHostKeyChecking no return ACLManager.loadError() return render(request, 'websiteFunctions/installPrestaShop.html', {'domainName': self.domain}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def installMagento(self, request=None, userID=None, data=None): @@ -2060,7 +2060,7 @@ StrictHostKeyChecking no return ACLManager.loadError() return render(request, 'websiteFunctions/installMagento.html', {'domainName': self.domain}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def magentoInstall(self, userID=None, data=None): @@ -2105,7 +2105,7 @@ StrictHostKeyChecking no ## 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) @@ -2152,7 +2152,7 @@ StrictHostKeyChecking no ## 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) @@ -2206,7 +2206,7 @@ StrictHostKeyChecking no 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) @@ -2223,7 +2223,7 @@ StrictHostKeyChecking no 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" @@ -2261,7 +2261,7 @@ StrictHostKeyChecking no 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" @@ -2368,7 +2368,7 @@ StrictHostKeyChecking no 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) @@ -2484,7 +2484,7 @@ StrictHostKeyChecking no 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): @@ -2515,7 +2515,7 @@ StrictHostKeyChecking no 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) @@ -2536,7 +2536,7 @@ StrictHostKeyChecking no return render(request, 'websiteFunctions/setupStaging.html', {'domainName': self.domain, 'externalApp': externalApp}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) @@ -2590,7 +2590,7 @@ StrictHostKeyChecking no 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) @@ -2611,7 +2611,7 @@ StrictHostKeyChecking no return render(request, 'websiteFunctions/syncMaster.html', {'domainName': self.domain, 'externalApp': externalApp, 'childDomain': childDomain}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) @@ -2671,7 +2671,7 @@ StrictHostKeyChecking no 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)