daboide Commit
Revision 721
Date: 2006-12-20 10:12:39 -0800 (Wed, 20 Dec 2006)
Author: Ed
Changed:
U branches/stable/wizards/AppWizard/AppWizard.py
Log:
This adds the necessary pathing so that no matter what directory the wizard is
run from, it can find its template files.
Diff:
Modified: branches/stable/wizards/AppWizard/AppWizard.py
===================================================================
--- branches/stable/wizards/AppWizard/AppWizard.py 2006-12-20 15:45:24 UTC
(rev 720)
+++ branches/stable/wizards/AppWizard/AppWizard.py 2006-12-20 18:12:39 UTC
(rev 721)
@@ -1,5 +1,7 @@
#!/usr/bin/env python
-import os, time
+import sys
+import os
+import time
import traceback
import dabo
from dabo.dLocalize import _
@@ -287,7 +289,7 @@
ci.Port = int(self.ctlPort.Value)
except ValueError:
ci.Port = None
- # Try to get a connection::
+ # Try to get a connection:
busy = dabo.ui.busyInfo(_("Connecting to database..."))
try:
conn = dabo.db.dConnection(ci)
@@ -719,7 +721,7 @@
txt = """Press 'Finish' to create your application, or
'Back' to edit any information."""
lbl = dLabel(self, Caption=txt)
- self.Sizer.append(lbl)
+ self.Sizer.append1x(lbl)
def onLeavePage(self, direction):
@@ -746,7 +748,8 @@
self.Caption = _("Dabo Application Wizard")
self.Image = "daboIcon064"
self.Size = (520, 560)
-
+
+ self.wizDir = os.getcwd()
self.tableDict = {}
self.selectedTables = []
self.tableRelations = []
@@ -759,7 +762,7 @@
self.useFieldSpecs = False
# egl: 2006.10.7 - removed the field specs and relations pages.
- pgs = [PageIntro, PageDatabase, PageTableSelection,
+ pgs = [PageIntro, PageDatabase, PageTableSelection,
PageOutput, PageGo]
self.append(pgs)
self.layout()
@@ -772,14 +775,12 @@
def createApp(self):
- directory = self.outputDirectory
-
+ directory = self.outputDirectory
if os.path.exists(directory):
td = self.tableDict
rd = self.tableRelationKeys
selTb = self.selectedTables
ci = self.connectInfo
- oldDir = os.getcwd()
os.chdir(directory)
appName = os.path.split(self.outputDirectory)[-1]
self.appKey = ".".join(("dabo", "app", appName))
@@ -795,7 +796,7 @@
f.close()
## Create the manifest file (for xp theme support):
- pth = os.path.join(self.Application.HomeDirectory,
"spec-main.exe.manifest")
+ pth = os.path.join(self.wizDir,
"spec-main.exe.manifest")
txt = open(pth).read() % dabo.defaultEncoding
open("./%s.exe.manifest" % appName, "w").write(txt)
@@ -895,7 +896,6 @@
f.close()
open("./__init__.py",
"w").write(self.getModuleInit_ui(uiImports))
-
# reports dir:
os.chdir("../reports")
@@ -930,12 +930,12 @@
(table.title(), table.title())))
forms = "".join((forms, """("-", None),\n\t\t\t\t"""))
- return open(os.path.join(self.Application.HomeDirectory,
+ return open(os.path.join(self.wizDir,
"spec-MenFileOpen.py.txt")).read() % locals()
def getReportsMenu(self):
- return open(os.path.join(self.Application.HomeDirectory,
+ return open(os.path.join(self.wizDir,
"spec-MenReports.py.txt")).read() % locals()
@@ -952,7 +952,7 @@
else:
fieldSpecs = ""
- return open(os.path.join(self.Application.HomeDirectory,
+ return open(os.path.join(self.wizDir,
"spec-Frm.py.txt")).read() % locals()
@@ -983,7 +983,7 @@
typ =
typeConversion.get(fieldDict[field]["type"], "char")
colDefs += colSpec % (field, typ, field)
- return open(os.path.join(self.Application.HomeDirectory,
+ return open(os.path.join(self.wizDir,
"spec-Grd.py.txt")).read() % locals()
@@ -1060,7 +1060,7 @@
self.itemsCreated = True
"""
- return open(os.path.join(self.Application.HomeDirectory,
+ return open(os.path.join(self.wizDir,
"spec-PagEdit.py.txt")).read() % locals()
@@ -1187,14 +1187,14 @@
return panel
"""
- return open(os.path.join(self.Application.HomeDirectory,
+ return open(os.path.join(self.wizDir,
"spec-PagSelect.py.txt")).read() % locals()
def getMain(self, dbConnectionDef, table):
tableName = table.title()
formOpenString = "\"Frm%s\" % form_name"
- return open(os.path.join(self.Application.HomeDirectory,
+ return open(os.path.join(self.wizDir,
"spec-main.py.txt")).read() % locals()
@@ -1204,38 +1204,38 @@
("ui", ["ui/fieldSpecs.fsxml",
"ui/relationSpecs.rsxml"]),"""
else:
data_files_fieldspecs = ""
- return open(os.path.join(self.Application.HomeDirectory,
+ return open(os.path.join(self.wizDir,
"spec-setup.py.txt")).read() % locals()
def getBuildwin(self):
- return open(os.path.join(self.Application.HomeDirectory,
+ return open(os.path.join(self.wizDir,
"spec-buildwin.bat")).read() % locals()
def getModuleInit_db(self):
- return open(os.path.join(self.Application.HomeDirectory,
+ return open(os.path.join(self.wizDir,
"spec-db__init__.py.txt")).read() % locals()
def getModuleInit_biz(self, bizImports):
lines = ["from %s import %s" % (class_, class_) for class_ in
bizImports]
bizInit = os.linesep.join(lines)
- return open(os.path.join(self.Application.HomeDirectory,
+ return open(os.path.join(self.wizDir,
"spec-biz__init__.py.txt")).read() % locals()
def getModuleInit_ui(self, uiImports):
lines = ["from %s import %s" % (class_, class_) for class_ in
uiImports]
uiInit = os.linesep.join(lines)
- return open(os.path.join(self.Application.HomeDirectory,
+ return open(os.path.join(self.wizDir,
"spec-ui__init__.py.txt")).read() % locals()
def getApp(self, appName):
appName = appName.title()
appKey = self.appKey
- return open(os.path.join(self.Application.HomeDirectory,
+ return open(os.path.join(self.wizDir,
"spec-App.py.txt")).read() % locals()
@@ -1248,7 +1248,7 @@
def getBaseBizobj(self):
- return open(os.path.join(self.Application.HomeDirectory,
+ return open(os.path.join(self.wizDir,
"spec-BizBase.py.txt")).read() % locals()
@@ -1283,52 +1283,52 @@
for field in sortedFieldNames:
fields += """self.addField("%s.%s as %s")\n\t\t""" %
(table, field[1], field[1])
- return open(os.path.join(self.Application.HomeDirectory,
+ return open(os.path.join(self.wizDir,
"spec-Biz.py.txt")).read() % locals()
def getGrdBase(self):
- return open(os.path.join(self.Application.HomeDirectory,
+ return open(os.path.join(self.wizDir,
"spec-GrdBase.py.txt")).read() % locals()
def getFrmBase(self):
- return open(os.path.join(self.Application.HomeDirectory,
+ return open(os.path.join(self.wizDir,
"spec-FrmBase.py.txt")).read() % locals()
def getFrmMain(self):
- return open(os.path.join(self.Application.HomeDirectory,
+ return open(os.path.join(self.wizDir,
"spec-FrmMain.py.txt")).read() % locals()
def getFrmReportBase(self):
- return open(os.path.join(self.Application.HomeDirectory,
+ return open(os.path.join(self.wizDir,
"spec-FrmReportBase.py.txt")).read() % locals()
def getFrmReportSample(self):
- return open(os.path.join(self.Application.HomeDirectory,
+ return open(os.path.join(self.wizDir,
"spec-FrmReportSample.py.txt")).read() %
locals()
def getPagBase(self, pageName):
- return open(os.path.join(self.Application.HomeDirectory,
+ return open(os.path.join(self.wizDir,
"spec-%s.py.txt" % pageName)).read() % locals()
def getVersion(self):
- return open(os.path.join(self.Application.HomeDirectory,
+ return open(os.path.join(self.wizDir,
"spec-__version__.py.txt")).read() % locals()
def getSampleDataSet(self):
- return open(os.path.join(self.Application.HomeDirectory,
+ return open(os.path.join(self.wizDir,
"spec-getSampleDataSet.py.txt")).read() %
locals()
def getSampleReport(self):
enc = dabo.defaultEncoding
- return open(os.path.join(self.Application.HomeDirectory,
+ return open(os.path.join(self.wizDir,
"spec-sampleReport.rfxml")).read() % locals()
@@ -1413,6 +1413,10 @@
app = dabo.dApp(BasePrefKey="dabo.ide.wizards.AppWizard")
app.setAppInfo("appName", "Dabo Application Wizard")
app.setAppInfo("appShortName", "AppWizard")
+
+ pth = os.path.split(sys.argv[0])[0]
+ if pth:
+ os.chdir(pth)
app.MainFormClass = None
app.setup()
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev