Thread: [Jahshaka-cvs] jah/jahplayer utilities.py,1.2,1.3
Status: Beta
Brought to you by:
jahshaka
From: Charles Y. <lil...@us...> - 2006-07-12 14:00:10
|
Update of /cvsroot/jahshaka/jah/jahplayer In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv1992 Modified Files: utilities.py Log Message: + Trace functionality (TODO: add a link to the original developer...) Index: utilities.py =================================================================== RCS file: /cvsroot/jahshaka/jah/jahplayer/utilities.py,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- utilities.py 30 Jun 2006 08:07:11 -0000 1.2 +++ utilities.py 12 Jul 2006 13:58:09 -0000 1.3 @@ -12,3 +12,20 @@ else: return mw, int( mw / ar ) return cw, ch + +import linecache +import random + +def traceit(frame, event, arg): + if event == "line": + lineno = frame.f_lineno + filename = frame.f_globals["__file__"] + if filename == "<stdin>": + filename = "traceit.py" + if filename.endswith(".pyc") or filename.endswith(".pyo"): + filename = filename[:-1] + name = frame.f_globals["__name__"] + line = linecache.getline(filename, lineno) + print "%s:%s: %s" % (name, lineno, line.rstrip()) + return traceit + |