Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def cleanup_logfiles(self, tasklist):
for task in tasklist:
try:
if not self.keep_logfiles:
if not task.has_error() or task.retcode == _KILLED_BY_ANYPYTOOLS:
silentremove(task.logfile)
task.logfile = ""
except OSError as e:
logger.debug("Could not remove " "{} {}".format(task.logfile, str(e)))
if not self.keep_logfiles and task.logfile:
try:
macrofile = Path(task.logfile).with_suffix(".anymcr")
silentremove(macrofile)
except OSError as e:
logger.debug(f"Could not remove: {macrofile} {e}")
task.processtime = time.time() - starttime
except KeyboardInterrupt as e:
task.processtime = 0
raise e
finally:
logfile.seek(0)
task.output = parse_anybodycon_output(
logfile.read(),
self.ignore_errors,
self.warnings_to_include,
fatal_warnings=self.fatal_warnings,
)
finally:
if not self.keep_logfiles and not task.has_error():
silentremove(logfile.name)
task.logfile = ""
task_queue.put(task)
def cleanup_logfiles(self, tasklist):
for task in tasklist:
try:
if not self.keep_logfiles:
if not task.has_error() or task.retcode == _KILLED_BY_ANYPYTOOLS:
silentremove(task.logfile)
task.logfile = ""
except OSError as e:
logger.debug("Could not remove " "{} {}".format(task.logfile, str(e)))
if not self.keep_logfiles and task.logfile:
try:
macrofile = Path(task.logfile).with_suffix(".anymcr")
silentremove(macrofile)
except OSError as e:
logger.debug(f"Could not remove: {macrofile} {e}")
_subprocess_container.remove(proc.pid)
retcode = ctypes.c_int32(proc.returncode).value
if retcode == _KILLED_BY_ANYPYTOOLS:
logfile.write("\nAnybodycon.exe was interrupted by AnyPyTools")
elif retcode == _NO_LICENSES_AVAILABLE:
logfile.write(
"\nERROR: anybodycon.exe existed unexpectedly. "
"Return code: " + str(_NO_LICENSES_AVAILABLE) + " : No license available."
)
elif retcode:
logfile.write(
"\nERROR: AnyPyTools : anybodycon.exe exited unexpectedly."
" Return code: " + str(retcode)
)
if not keep_macrofile:
silentremove(macro_file.name)
return retcode