473,395 Members | 1,452 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to extract complete file path from traceback info

I have a need to customize the output of Python error tracebacks,
and to that end I've implemented my own sys.excepthook function.
However, one remaining problem that I'm having is the information
passed to this function doesn't seem to have the _full_ path name
of the file in which the exception occurred. I need this because
the output is being parsed by an editor (jEdit) which uses this
information to set up links to errors origins in the source
code.

Is there an easy way to get this info somehow? (I haven't been
able to find it.) I can think of some 'solutions' I'd prefer
not to attempt unless I have to.

Thanks,
Ken McDonald
Jul 18 '05 #1
2 1977
Kenneth McDonald wrote:
I have a need to customize the output of Python error tracebacks,
and to that end I've implemented my own sys.excepthook function.
However, one remaining problem that I'm having is the information
passed to this function doesn't seem to have the _full_ path name
of the file in which the exception occurred. I need this because
the output is being parsed by an editor (jEdit) which uses this
information to set up links to errors origins in the source
code.

Is there an easy way to get this info somehow? (I haven't been
able to find it.) I can think of some 'solutions' I'd prefer
not to attempt unless I have to.


Searching the source for the traceback module, I saw that it
calls code in the linecache module which apparently has to
do a manual search down the sys.path to find the files that
are imported... that probably means (a) there is no other
way to do it, (b) there's example code for you in linecache.py,
and (c) it might have some troubles with the new zip-file
based imports etc... (not that that would be a particular
problem in your case, but it could confuse things).

-Peter
Jul 18 '05 #2
Am Fri, 18 Jun 2004 21:31:03 +0000 schrieb Kenneth McDonald:
I have a need to customize the output of Python error tracebacks,
and to that end I've implemented my own sys.excepthook function.
However, one remaining problem that I'm having is the information
passed to this function doesn't seem to have the _full_ path name
of the file in which the exception occurred. I need this because
the output is being parsed by an editor (jEdit) which uses this
information to set up links to errors origins in the source
code.

Is there an easy way to get this info somehow? (I haven't been
able to find it.) I can think of some 'solutions' I'd prefer
not to attempt unless I have to.


Hi Kenneth,

AFAIK, the module cgitb does this. Take a look at it.

HTH,
Thomas
Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Dustin Lee | last post by:
Seems like py-complete.el offers some cool features, if I could only get it to work. >From the file ;; 1. hippie-expand support via try-complete-py-complete-symbol, ;; just like the...
12
by: Anders Eriksson | last post by:
Hello! I'm trying to create a program that will watch a directory and when a file is created print that file. I have used FileSystemWatcher for watching the directory and I get an created event....
5
by: steve | last post by:
How can someone extract the file name and file path from a complete path? ex: c:\mydir\subdir\temp\myfile.txt will give: path = c:\mydir\subdir\temp filename = myfile.txt TIA
0
by: centur | last post by:
I need to acquire content body of MIME encoded message (as IMessage object).I want using C# and CDO Interop extract such data ("eJ8+IggVAQaQ..." unicode part). Here is example of Bodypart...
1
by: metaperl.etc | last post by:
In this traceback, the path to 3 different SQL Alchemy source files is a relative directory. However, no such directory is below my current working directory. This is problematic for two...
4
by: tasahmed | last post by:
Hello Friends, I wrote a function which scans the current working directory and lists out details such as directory/file owner, permission etc. The output of this script can be viewing in the...
3
by: yinglcs | last post by:
Hi, i have 2 python files in *different directory* , how can I import python functions from 1 python file to another? i get this error: import task ImportError: No module named task/ Thank...
3
by: adimangla | last post by:
Hi :-) I am creating a software that will save the present state of all the applications running on the desktop (WinXP). Can anyone point out the method to extract the filenames from the...
34
by: Alexnb | last post by:
Gerhard Häring wrote: No, it didn't work, but it gave me some interesting feedback when I ran it in the shell. Heres what it told me: Traceback (most recent call last): File...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.