Wrong path is passed to internal methods

Bug #316691 reported by Marco Ferreira
2
Affects Status Importance Assigned to Milestone
Gladex
Fix Committed
Undecided
Unassigned

Bug Description

Hello!

This occurs when trying to run the generated code from within the directory of the generated files:

setas@work:~/dev.testing/Sync&Run$ python SyncRun_RemoteBT.py
Traceback (most recent call last):
  File "SyncRun_RemoteBT.py", line 11, in <module>
    compile(os.path.split(__file__)[0]+"/"+"SyncRun_RemoteBT_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: '/SyncRun_RemoteBT_callbacks.py'

My suggestion is to check for the value of os.path.split(__file__)[0] (in case is "").

Cheers

Changed in gladex:
assignee: nobody → francesco-marella
status: New → Fix Committed
assignee: francesco-marella → nobody
Revision history for this message
sjgcit (sg-euroapps) wrote :

I do not think the proposed fix does not address the problem.

The underlying issue is that __file__ when split has an empty path. This can occur if the application is run from the command line locally.

I think the correct fix is to replace ALL occurrences of os.path.split(__file__) with os.path.split( os.path.abspath( __file__ ) )

This method always returns a valid path and leafname and avoid replicating checking code every time the path is needed.

I'd suggest setting a global ( to hold that path result ) during initialisation. This would avoid making multiple calls to two functions that are going to return what will be a constant during runtime.

Please note this issue ALSO occurs in generated code. Generated code should also use this approach ( because we don't know that the resulting code is not going to be executed locally from a command line ).

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.