Merge pull request #140 from stasinopoulos/patch-1

IOError exception handling
This commit is contained in:
trustedsec 2015-08-03 08:27:51 -07:00
commit f2e7bbd5d0

View file

@ -724,20 +724,22 @@ def windows_root():
# core log file routine for SET # core log file routine for SET
# #
def log(error): def log(error):
try:
# open log file only if directory is present (may be out of directory for some reason) # open log file only if directory is present (may be out of directory for some reason)
if not os.path.isfile("%s/src/logs/set_logfile.log" % (definepath())): if not os.path.isfile("%s/src/logs/set_logfile.log" % (definepath())):
filewrite = file("%s/src/logs/set_logfile.log" % (definepath()), "w") filewrite = file("%s/src/logs/set_logfile.log" % (definepath()), "w")
filewrite.write("") filewrite.write("")
filewrite.close() filewrite.close()
if os.path.isfile("%s/src/logs/set_logfile.log" % (definepath())): if os.path.isfile("%s/src/logs/set_logfile.log" % (definepath())):
error = str(error) error = str(error)
# open file for writing # open file for writing
filewrite = file("%s/src/logs/set_logfile.log" % (definepath()), "a") filewrite = file("%s/src/logs/set_logfile.log" % (definepath()), "a")
# write error message out # write error message out
filewrite.write("ERROR: " + date_time() + ": " + error + "\n") filewrite.write("ERROR: " + date_time() + ": " + error + "\n")
# close the file # close the file
filewrite.close() filewrite.close()
except IOError as err:
pass
# #
# upx encoding and modify binary # upx encoding and modify binary
# #