summaryrefslogtreecommitdiff
path: root/portato/helper.py
diff options
context:
space:
mode:
authornecoro <>2007-03-10 19:19:33 +0000
committernecoro <>2007-03-10 19:19:33 +0000
commitc399a6690b7981f1bd6c513666c4b37d71b5a855 (patch)
treeef7139b59f315390811d2e8fc8c7e628e25e6449 /portato/helper.py
parent50aa869c3f35a4646009f2cbc1a16f555f3914a8 (diff)
downloadportato-c399a6690b7981f1bd6c513666c4b37d71b5a855.tar.gz
portato-c399a6690b7981f1bd6c513666c4b37d71b5a855.tar.bz2
portato-c399a6690b7981f1bd6c513666c4b37d71b5a855.zip
First plugin support
Diffstat (limited to 'portato/helper.py')
-rw-r--r--portato/helper.py18
1 files changed, 14 insertions, 4 deletions
diff --git a/portato/helper.py b/portato/helper.py
index d66e256..b41dbbe 100644
--- a/portato/helper.py
+++ b/portato/helper.py
@@ -10,7 +10,7 @@
#
# Written by René 'Necoro' Neumann <necoro@necoro.net> et.al.
-import traceback, os.path
+import traceback, os.path, sys
DEBUG = True
@@ -33,7 +33,7 @@ def debug(*args, **kwargs):
If you pass the optional keyword-argument "name", it is used for the function-name instead of the original one."""
- if not DEBUG : return
+ if not DEBUG and not ("warn" in kwargs or "error" in kwargs): return
stack = traceback.extract_stack()
minus = -2
@@ -50,14 +50,24 @@ def debug(*args, **kwargs):
else:
text = 'In %s (%s:%s): %s' % (c, a, b, text)
- text = "***DEBUG*** %s ***DEBUG***" % text
+ outfile = sys.stdout
+ surround = "DEBUG"
+
+ if "warn" in kwargs:
+ outfile = sys.stderr
+ surround = "WARNING"
+ elif "error" in kwargs:
+ outfile = sys.stderr
+ surround = "ERROR"
+
+ text = ("***%s*** %s ***%s***" % (surround, text, surround))
if "file" in kwargs:
f = open(kwargs["file"], "a+")
f.write(text+"\n")
f.close()
else:
- print text
+ print >> outfile, text
def am_i_root ():
"""Returns True if the current user is root, False otherwise.