Skip to content

Commit fa38002

Browse files
committed
bug fix: emails
1 parent 92d7636 commit fa38002

4 files changed

Lines changed: 12 additions & 22 deletions

File tree

plogical/CyberCPLogFileWriter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def writeToFile(message):
1313
"%m.%d.%Y_%H-%M-%S") + "] "+ message + "\n")
1414
file.close()
1515

16-
except IOError as msg:
16+
except BaseException as msg:
1717
return "Can not write to error file."
1818

1919
@staticmethod
@@ -24,7 +24,7 @@ def writeforCLI(message, level, method):
2424
"%m.%d.%Y_%H-%M-%S") + "] [" + level + ":" + method + "] " + message + "\n")
2525
file.close()
2626
file.close()
27-
except IOError:
27+
except BaseException:
2828
return "Can not write to error file!"
2929

3030
@staticmethod

plogical/mailUtilities.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,21 +134,18 @@ def createEmailAccount(domain, userName, password):
134134

135135
emailDomain = Domains.objects.get(domain=domain)
136136

137-
hash = hashlib.md5()
138-
hash.update(password)
139-
140137
#emailAcct = EUsers(emailOwner=emailDomain, email=finalEmailUsername, password=hash.hexdigest())
141138

142139
CentOSPath = '/etc/redhat-release'
143140

144141
if os.path.exists(CentOSPath):
145-
password = bcrypt.hashpw(str(password), bcrypt.gensalt())
142+
password = bcrypt.hashpw(password.encode('utf-8'), bcrypt.gensalt())
146143
password = '{CRYPT}%s' % (password)
147144
emailAcct = EUsers(emailOwner=emailDomain, email=finalEmailUsername, password=password)
148145
emailAcct.mail = 'maildir:/home/vmail/%s/%s/Maildir' % (domain, userName)
149146
emailAcct.save()
150147
else:
151-
password = bcrypt.hashpw(str(password), bcrypt.gensalt())
148+
password = bcrypt.hashpw(password.encode('utf-8'), bcrypt.gensalt())
152149
password = '{CRYPT}%s' % (password)
153150
emailAcct = EUsers(emailOwner=emailDomain, email=finalEmailUsername, password=password)
154151
emailAcct.mail = 'maildir:/home/vmail/%s/%s/Maildir' % (domain, userName)

plogical/processUtilities.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -188,25 +188,22 @@ def sendCommand(command, user=None):
188188
sock.sendall(command.encode('utf-8'))
189189

190190
data = ""
191-
dataSTR = ""
192191

193192
while (1):
194193
currentData = sock.recv(32)
195194
if len(currentData) == 0 or currentData == None:
196195
break
197196
try:
198-
data = data + currentData.decode(encoding = 'UTF-8',errors = 'ignore')
197+
data = data + currentData.decode(errors = 'ignore')
199198
except BaseException as msg:
200199
logging.writeToFile('Some data could not be decoded to str, error message: %s' % str(msg))
201200

202-
dataSTR = dataSTR + str(currentData)
203-
204-
205201
sock.close()
206-
logging.writeToFile('Final data: %s.' % (dataSTR))
207-
return data, dataSTR
202+
logging.writeToFile('Final data: %s.' % (str(data)))
203+
204+
return data
208205
except BaseException as msg:
209-
logging.writeToFile(str(msg) + " [sendCommand]")
206+
logging.writeToFile(str(msg) + " [hey:sendCommand]")
210207
return "0" + str(msg)
211208

212209
@staticmethod
@@ -216,7 +213,7 @@ def executioner(command, user=None):
216213
ProcessUtilities.normalExecutioner(command)
217214
return 1
218215

219-
ret, dataSTR = ProcessUtilities.sendCommand(command, user)
216+
ret = ProcessUtilities.sendCommand(command, user)
220217

221218
exitCode = ret[len(ret) -1]
222219
exitCode = int(codecs.encode(exitCode.encode(), 'hex'))
@@ -238,8 +235,8 @@ def outputExecutioner(command, user=None):
238235

239236
if type(command) == list:
240237
command = " ".join(command)
241-
data, dataSTR = ProcessUtilities.sendCommand(command, user)
242-
return dataSTR[:-1]
238+
239+
return ProcessUtilities.sendCommand(command, user)[:-1]
243240
except BaseException as msg:
244241
logging.writeToFile(str(msg) + "[outputExecutioner:188]")
245242

plogical/test.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +0,0 @@
1-
import subprocess
2-
import shlex
3-
4-
print(subprocess.check_output(shlex.split('ls -la')).decode("utf-8"))

0 commit comments

Comments
 (0)