Debug - issue with "locale" folder not being found

2 views
Skip to first unread message

werner

unread,
Oct 3, 2011, 3:07:46 AM10/3/11
to edi...@googlegroups.com
My folder struct is:
devProjectsWv
- twcbv4
-- twcbsrc
--- locale
--- model
--- controllers
--- etc etc

If I launch e.g. controllers/country from within the package/folder it
works fine and finds the locale files, but if I debug it then I get an
exception.

country.py has this to run it for testing only, normally it will be
invoked from within my main frame/controller (which is not yet written):

if __name__ == '__main__':
#change working dir for translation files to be found, if running test
import os
os.chdir("..")
print 'cd: %s' % os.getcwd()

import twcbsrc.app_base as ab
# redirect has to be set to False otherwise we get strange crashes
# on e.g. Windows 7 64 bit
app = ab.BaseApp(redirect=False)
app.CloseSplash()

c = Country(None, standalone = True)
etc etc

If I launch it the "print cd" gives me:
cd: C:\devProjectsWv\twcbv4\twcbsrc

When I debug it I get:
cd: C:\devProjectsWv

The debug command is:
Rpdb2 command line: c:\python27\python.exe -u
C:\Users\wbruhin\AppData\Roaming\Python-Eggs\pystudio-0.4-py2.7.egg-tmp\rpdb2.py
-d --pwd=editra123 twcbsrc\controllers\country.py

Is there an issue with pydebug, or my setup, or can I detect in the
script that I am debugging and adjust my os.chdir?

Werner

werner

unread,
Oct 3, 2011, 4:09:53 AM10/3/11
to edi...@googlegroups.com
I fixed this on my side by having better code in my BaseApp, use
__file__ to get to the basedir instead of os.getcwd.

import gettext
basedir, f = os.path.split(__file__)
localeDir = os.path.join(basedir, 'locale')

Werner

Reply all
Reply to author
Forward
0 new messages