diff --git a/plogical/CyberCPLogFileWriter.py b/plogical/CyberCPLogFileWriter.py index ab75636dc..5b2539bfa 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 as msg: + except BaseException as msg: return "Can not write to error file." @staticmethod @@ -24,7 +24,7 @@ class CyberCPLogFileWriter: "%m.%d.%Y_%H-%M-%S") + "] [" + level + ":" + method + "] " + message + "\n") file.close() file.close() - except IOError: + except BaseException: return "Can not write to error file!" @staticmethod diff --git a/plogical/mailUtilities.py b/plogical/mailUtilities.py index 8b7dcf2e7..144dc2cb4 100755 --- a/plogical/mailUtilities.py +++ b/plogical/mailUtilities.py @@ -134,21 +134,18 @@ class mailUtilities: emailDomain = Domains.objects.get(domain=domain) - hash = hashlib.md5() - hash.update(password) - #emailAcct = EUsers(emailOwner=emailDomain, email=finalEmailUsername, password=hash.hexdigest()) CentOSPath = '/etc/redhat-release' if os.path.exists(CentOSPath): - password = bcrypt.hashpw(str(password), bcrypt.gensalt()) + password = bcrypt.hashpw(password.encode('utf-8'), bcrypt.gensalt()) password = '{CRYPT}%s' % (password) emailAcct = EUsers(emailOwner=emailDomain, email=finalEmailUsername, password=password) emailAcct.mail = 'maildir:/home/vmail/%s/%s/Maildir' % (domain, userName) emailAcct.save() else: - password = bcrypt.hashpw(str(password), bcrypt.gensalt()) + password = bcrypt.hashpw(password.encode('utf-8'), bcrypt.gensalt()) password = '{CRYPT}%s' % (password) emailAcct = EUsers(emailOwner=emailDomain, email=finalEmailUsername, password=password) emailAcct.mail = 'maildir:/home/vmail/%s/%s/Maildir' % (domain, userName) diff --git a/plogical/processUtilities.py b/plogical/processUtilities.py index 8cc53f95f..7d753af60 100755 --- a/plogical/processUtilities.py +++ b/plogical/processUtilities.py @@ -188,25 +188,22 @@ class ProcessUtilities(multi.Thread): sock.sendall(command.encode('utf-8')) data = "" - dataSTR = "" while (1): currentData = sock.recv(32) if len(currentData) == 0 or currentData == None: break try: - data = data + currentData.decode(encoding = 'UTF-8',errors = 'ignore') + data = data + currentData.decode(errors = 'ignore') except BaseException as msg: logging.writeToFile('Some data could not be decoded to str, error message: %s' % str(msg)) - dataSTR = dataSTR + str(currentData) - - sock.close() - logging.writeToFile('Final data: %s.' % (dataSTR)) - return data, dataSTR + logging.writeToFile('Final data: %s.' % (str(data))) + + return data except BaseException as msg: - logging.writeToFile(str(msg) + " [sendCommand]") + logging.writeToFile(str(msg) + " [hey:sendCommand]") return "0" + str(msg) @staticmethod @@ -216,7 +213,7 @@ class ProcessUtilities(multi.Thread): ProcessUtilities.normalExecutioner(command) return 1 - ret, dataSTR = ProcessUtilities.sendCommand(command, user) + ret = ProcessUtilities.sendCommand(command, user) exitCode = ret[len(ret) -1] exitCode = int(codecs.encode(exitCode.encode(), 'hex')) @@ -238,8 +235,8 @@ class ProcessUtilities(multi.Thread): if type(command) == list: command = " ".join(command) - data, dataSTR = ProcessUtilities.sendCommand(command, user) - return dataSTR[:-1] + + return ProcessUtilities.sendCommand(command, user)[:-1] except BaseException as msg: logging.writeToFile(str(msg) + "[outputExecutioner:188]") diff --git a/plogical/test.py b/plogical/test.py index d840ef7cb..e69de29bb 100755 --- a/plogical/test.py +++ b/plogical/test.py @@ -1,4 +0,0 @@ -import subprocess -import shlex - -print(subprocess.check_output(shlex.split('ls -la')).decode("utf-8")) \ No newline at end of file