summaryrefslogtreecommitdiff
path: root/portato/helper.py
diff options
context:
space:
mode:
authornecoro <>2007-02-04 03:09:41 +0000
committernecoro <>2007-02-04 03:09:41 +0000
commitf9c72a988bee77efd6a6f3069d3c460fff23c9cc (patch)
treeb9878e581808edbf85bca9d34759ea6fa31bf99f /portato/helper.py
parent108cf5bd89ea15349769a628a38671797c6bcc12 (diff)
downloadportato-f9c72a988bee77efd6a6f3069d3c460fff23c9cc.tar.gz
portato-f9c72a988bee77efd6a6f3069d3c460fff23c9cc.tar.bz2
portato-f9c72a988bee77efd6a6f3069d3c460fff23c9cc.zip
Added file support for debug (merged from curses-branch)
Diffstat (limited to 'portato/helper.py')
-rw-r--r--portato/helper.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/portato/helper.py b/portato/helper.py
index 2a492cc..fab8aa5 100644
--- a/portato/helper.py
+++ b/portato/helper.py
@@ -36,7 +36,10 @@ def debug(*args, **kwargs):
if not DEBUG : return
stack = traceback.extract_stack()
- a, b, c, d = stack[-2]
+ minus = -2
+ if "minus" in kwargs:
+ minus = minus - kwargs["minus"]
+ a, b, c, d = stack[minus]
a = os.path.basename(a)
out = []
for obj in args:
@@ -49,7 +52,12 @@ def debug(*args, **kwargs):
text = "***DEBUG*** %s ***DEBUG***" % text
- print text
+ if "file" in kwargs:
+ f = open(kwargs["file"], "a+")
+ f.write(text+"\n")
+ f.close()
+ else:
+ print text
def am_i_root ():
"""Returns True if the current user is root, False otherwise.