dabo Commit
Revision 5564
Date: 2009-12-27 10:01:40 -0800 (Sun, 27 Dec 2009)
Author: Ed
Trac: http://trac.dabodev.com/changeset/5564
Changed:
U trunk/dabo/dApp.py
Log:
Fixed some issues with establishing HomeDirectory when running from the runtime
engine.
Diff:
Modified: trunk/dabo/dApp.py
===================================================================
--- trunk/dabo/dApp.py 2009-12-26 20:41:07 UTC (rev 5563)
+++ trunk/dabo/dApp.py 2009-12-27 18:01:40 UTC (rev 5564)
@@ -1370,36 +1370,45 @@
try:
hd = self._homeDirectory
except AttributeError:
- # Get the script name that launched the app. In case it
was run
- # as an executable, strip the leading './'
- calledScript = sys.argv[0]
- if calledScript.startswith("./"):
- calledScript = calledScript.lstrip("./")
- scriptDir =
os.path.realpath(os.path.split(os.path.join(os.getcwd(), calledScript))[0])
- appDir =
os.path.realpath(os.path.split(inspect.getabsfile(self.__class__))[0])
+ # See if we're running in Runtime Engine mode.
+ try:
+ hd = sys._daboRunHomeDir
+ except AttributeError:
+ calledScript = None
+ try:
+ # Get the script name that launched the
app. In case it was run
+ # as an executable, strip the leading
'./'
+ calledScript = sys.argv[0]
+ except IndexError:
+ # Give up... just assume the current
directory.
+ hd = os.getcwd()
+ if calledScript:
+ if calledScript.startswith("./"):
+ calledScript =
calledScript.lstrip("./")
+ scriptDir =
os.path.realpath(os.path.split(os.path.join(os.getcwd(), calledScript))[0])
+ appDir =
os.path.realpath(os.path.split(inspect.getabsfile(self.__class__))[0])
+ def issubdir(d1, d2):
+ while True:
+ if len(d1) < len(d2) or
len(d1) <= 1:
+ return False
+ d1 =
os.path.split(d1)[0]
+ if d1 == d2:
+ return True
- def issubdir(d1, d2):
- while True:
- if len(d1) < len(d2) or len(d1) <= 1:
- return False
- d1 = os.path.split(d1)[0]
- if d1 == d2:
- return True
+ if issubdir(scriptDir, appDir):
+ # The directory where the main
script is executing is a subdirectory of the
+ # location of the application
object in use. So we can safely make the app
+ # directory the HomeDirectory.
+ hd = appDir
+ else:
+ # The directory where the main
script is executing is *not* a subdirectory
+ # of the location of the app
object in use. The app object is likely an
+ # instance of a raw dApp. So
the only thing we can really do is make the
+ # HomeDirectory the location of
the main script, since we can't guess at
+ # the application's directory
structure.
+ dabo.infoLog.write("Can't
deduce HomeDirectory:setting to the script directory.")
+ hd = scriptDir
- if issubdir(scriptDir, appDir):
- # The directory where the main script is
executing is a subdirectory of the
- # location of the application object in use. So
we can safely make the app
- # directory the HomeDirectory.
- hd = appDir
- else:
- # The directory where the main script is
executing is *not* a subdirectory
- # of the location of the app object in use. The
app object is likely an
- # instance of a raw dApp. So the only thing we
can really do is make the
- # HomeDirectory the location of the main
script, since we can't guess at
- # the application's directory structure.
- dabo.infoLog.write("Can't deduce
HomeDirectory:setting to the script directory.")
- hd = scriptDir
-
if os.path.split(hd)[1][-4:].lower() in (".zip",
".exe"):
# mangle HomeDirectory to not be the py2exe
library.zip file,
# but the containing directory (the directory
where the exe lives)
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message:
http://leafe.com/archives/byMID/[email protected]