mirror of
https://github.com/fergalmoran/picard.git
synced 2025-12-22 09:18:18 +00:00
PICARD-1718: Use NamedTemporaryFile for creating log file
This commit is contained in:
@@ -23,13 +23,13 @@ except SystemExit:
|
||||
except: # noqa: F722
|
||||
# First try to get traceback information and write it to a log file
|
||||
# with minimum chance to fail.
|
||||
import tempfile
|
||||
from tempfile import NamedTemporaryFile
|
||||
import traceback
|
||||
trace = traceback.format_exc()
|
||||
try:
|
||||
(fd, logfile) = tempfile.mkstemp(".log", "picard-crash-")
|
||||
os.write(fd, trace.encode(errors="replace"))
|
||||
os.close(fd)
|
||||
with NamedTemporaryFile(suffix='.log', prefix='picard-crash-', delete=False) as f:
|
||||
f.write(trace.encode(errors="replace"))
|
||||
logfile = f.name
|
||||
except: # noqa: F722
|
||||
print("Failed writing log file {0}".format(logfile), file=sys.stderr)
|
||||
logfile = None
|
||||
|
||||
Reference in New Issue
Block a user