command "python gladefilename.py" returns errors

Bug #197515 reported by Christopher Pax
2
Affects Status Importance Assigned to Milestone
Gladex
Fix Committed
Medium
Christopher Pax

Bug Description

To replicate this bug,
1. Open gladex, load example, set output directory to Desktop and hit excute.
2. Open a terminal and change the directory to that folder, Desktop. (cd ~/Desktop)
3. Try running the example like this. ($: python example.py)
the fallowing error displays:
Traceback (most recent call last):
  File "example.py", line 11, in <module>
    compile(os.path.split(__file__)[0]+"/"+"example_callbacks.py")
  File "/usr/lib/python2.5/py_compile.py", line 115, in compile
    f = open(file, 'U')
IOError: [Errno 2] No such file or directory: '/example_callbacks.py'

The solution. when you execute the code like this: $: python example.py
os.path.split(__file__)[0] will result as a empty string.
the solution here is to say.
gpath = os.path.split(__file__)[0]
if gpath == "": gpath = "."
this will make the compile line (as you see in the error), and other lines, look like this:
"./example_callbacks.py" to denote that the file is in the working directory.

Changed in gladex:
assignee: nobody → paxmanchris
importance: Undecided → Medium
milestone: none → 0.4
status: New → In Progress
Revision history for this message
Christopher Pax (paxmanchris) wrote :

fix in 0.4 revision 145 and in trunk 156

Changed in gladex:
status: In Progress → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.