Warning

This document is for an old release of Galaxy. You can alternatively view this page in the latest release if it exists or view the top of the latest release's documentation.

Source code for log_tempfile

# override tempfile methods for debugging
import logging
import tempfile
import traceback

log = logging.getLogger(__name__)


[docs]class TempFile(object):
[docs] def __init__(self): tempfile._NamedTemporaryFile = tempfile.NamedTemporaryFile tempfile._mkstemp = tempfile.mkstemp tempfile.NamedTemporaryFile = self.NamedTemporaryFile tempfile.mkstemp = self.mkstemp
[docs] 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
[docs] 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