Files
galaxy/lib/log_tempfile.py
T
Nicola Soranzo 21b44bf348 Fix all E201 and E202 style errors
using the following command:
```
autopep8 -i -r --exclude $(sed -e 's|^|./|' -e 's|/$||' .ci/flake8_blacklist.txt | paste -sd,) --select E201,E202 .
```
2017-08-17 11:35:39 +01:00

31 lines
961 B
Python

# override tempfile methods for debugging
import logging
import tempfile
import traceback
log = logging.getLogger(__name__)
class TempFile(object):
def __init__(self):
tempfile._NamedTemporaryFile = tempfile.NamedTemporaryFile
tempfile._mkstemp = tempfile.mkstemp
tempfile.NamedTemporaryFile = self.NamedTemporaryFile
tempfile.mkstemp = self.mkstemp
def NamedTemporaryFile(self, *args, **kwargs):
f = tempfile._NamedTemporaryFile(*args, **kwargs)
try:
log.debug(("Opened tempfile %s with NamedTemporaryFile:\n" % f.name) + "".join(traceback.format_stack()))
except AttributeError:
pass
return f
def mkstemp(self, *args, **kwargs):
f = tempfile._mkstemp(*args, **kwargs)
try:
log.debug(("Opened tempfile %s with mkstemp:\n" % f[1]) + "".join(traceback.format_stack()))
except TypeError:
pass
return f