Skip to content
Snippets Groups Projects
Commit 7b4e0e42 authored by Andreas Klöckner's avatar Andreas Klöckner
Browse files

Fix get_run_debug_directory()

parent eee785ae
No related branches found
No related tags found
No related merge requests found
from pytools import memoize from pytools import memoize
# {{{ debug files ------------------------------------------------------------- # {{{ debug files -------------------------------------------------------------
def make_unique_filesystem_object(stem, extension="", directory="", def make_unique_filesystem_object(stem, extension="", directory="",
...@@ -28,8 +26,6 @@ def make_unique_filesystem_object(stem, extension="", directory="", ...@@ -28,8 +26,6 @@ def make_unique_filesystem_object(stem, extension="", directory="",
i += 1 i += 1
@memoize @memoize
def get_run_debug_directory(): def get_run_debug_directory():
def creator(name): def creator(name):
...@@ -37,9 +33,7 @@ def get_run_debug_directory(): ...@@ -37,9 +33,7 @@ def get_run_debug_directory():
mkdir(name) mkdir(name)
return name return name
return make_unique_filesystem_object("run-debug", creator=creator) return make_unique_filesystem_object("run-debug", creator=creator)[0]
def open_unique_debug_file(stem, extension=""): def open_unique_debug_file(stem, extension=""):
...@@ -51,10 +45,13 @@ def open_unique_debug_file(stem, extension=""): ...@@ -51,10 +45,13 @@ def open_unique_debug_file(stem, extension=""):
# }}} # }}}
# {{{ refcount debugging ------------------------------------------------------ # {{{ refcount debugging ------------------------------------------------------
class RefDebugQuit(Exception): class RefDebugQuit(Exception):
pass pass
def refdebug(obj, top_level=True, exclude=[]): def refdebug(obj, top_level=True, exclude=[]):
from types import FrameType from types import FrameType
...@@ -107,7 +104,7 @@ def refdebug(obj, top_level=True, exclude=[]): ...@@ -107,7 +104,7 @@ def refdebug(obj, top_level=True, exclude=[]):
response = raw_input() response = raw_input()
if response =="d": if response == "d":
refdebug(r, top_level=False, exclude=exclude+[reflist]) refdebug(r, top_level=False, exclude=exclude+[reflist])
print_head = True print_head = True
elif response == "n": elif response == "n":
...@@ -137,6 +134,7 @@ def refdebug(obj, top_level=True, exclude=[]): ...@@ -137,6 +134,7 @@ def refdebug(obj, top_level=True, exclude=[]):
# }}} # }}}
# {{{ interactive shell # {{{ interactive shell
def get_shell_hist_filename(): def get_shell_hist_filename():
...@@ -144,11 +142,12 @@ def get_shell_hist_filename(): ...@@ -144,11 +142,12 @@ def get_shell_hist_filename():
_home = os.environ.get('HOME', '/') _home = os.environ.get('HOME', '/')
return os.path.join(_home, ".pytools-debug-shell-history") return os.path.join(_home, ".pytools-debug-shell-history")
def setup_readline(): def setup_readline():
try: try:
readline.read_history_file(get_shell_hist_filename()) readline.read_history_file(get_shell_hist_filename())
except Exception: except Exception:
# http://docs.python.org/3/howto/pyporting.html#capturing-the-currently-raised-exception # http://docs.python.org/3/howto/pyporting.html#capturing-the-currently-raised-exception # noqa
import sys import sys
e = sys.exc_info()[1] e = sys.exc_info()[1]
...@@ -166,6 +165,7 @@ except ImportError: ...@@ -166,6 +165,7 @@ except ImportError:
else: else:
setup_readline() setup_readline()
class SetPropagatingDict(dict): class SetPropagatingDict(dict):
def __init__(self, source_dicts, target_dict): def __init__(self, source_dicts, target_dict):
dict.__init__(self) dict.__init__(self)
...@@ -182,6 +182,7 @@ class SetPropagatingDict(dict): ...@@ -182,6 +182,7 @@ class SetPropagatingDict(dict):
dict.__delitem__(self, key) dict.__delitem__(self, key)
del self.target_dict[key] del self.target_dict[key]
def shell(locals=None, globals=None): def shell(locals=None, globals=None):
from inspect import currentframe, getouterframes from inspect import currentframe, getouterframes
calling_frame = getouterframes(currentframe())[1][0] calling_frame = getouterframes(currentframe())[1][0]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment