|
[Webware-checkins] CVS: Webware/bin MakeAppWorkDir.py,1.19,1.20
From: Ian Bicking <ianbicking@us...> - 2004-05-26 06:56
|
Update of /cvsroot/webware/Webware/bin
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21934/bin
Modified Files:
MakeAppWorkDir.py
Log Message:
* Configuration files can now be written as Python modules, where the
global variables are keys in the configuration dictionary. Old
configuration files are still supported.
* The default configuration files have updated with this new, more
pleasant syntax.
* MakeAppWorkDir.py and install.py parse the new configuration files.
* MakeAppWorkDir.py accepts a couple new options -- one to set the
default context's home directory, and another to add library directories
to the path (a generalization of the --library option).
Index: MakeAppWorkDir.py
===================================================================
RCS file: /cvsroot/webware/Webware/bin/MakeAppWorkDir.py,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** MakeAppWorkDir.py 15 Jan 2003 20:56:02 -0000 1.19
--- MakeAppWorkDir.py 26 May 2004 06:56:20 -0000 1.20
***************
*** 8,15 ****
#----------------------------------------------------------------------
! """
MakeAppWorkDir.py
-
INTRODUCTION
--- 8,14 ----
#----------------------------------------------------------------------
! """\
MakeAppWorkDir.py
INTRODUCTION
***************
*** 30,36 ****
-c SampleContextName "SampleContextName" will be used for the pre-
installed context. (Default "MyContext")
--cvsignore .cvsignore files will be added
! -l or --library A lib/ directory will be added, which will
! added to the Python the path for the AppServer
"""
--- 29,38 ----
-c SampleContextName "SampleContextName" will be used for the pre-
installed context. (Default "MyContext")
+ -d SampleContextDir The directory where the context will be located
+ (so you can place the context outside of the
+ workdir).
--cvsignore .cvsignore files will be added
! -l Dir You may specify this option multiple times; all
! or --library Dir directories you give will be added to sys.path.
"""
***************
*** 52,57 ****
def __init__(self, webWareDir, workDir, verbose=1,
! sampleContext="MyContext", osType=None,
! addCVSIgnore=0, makeLibrary=0):
"""Initializer for MakeAppWorkDir. Pass in at least the
Webware directory and the target working directory. If you
--- 54,62 ----
def __init__(self, webWareDir, workDir, verbose=1,
! sampleContext="MyContext",
! contextDir='',
! osType=None,
! addCVSIgnore=0,
! libraryDirs=None):
"""Initializer for MakeAppWorkDir. Pass in at least the
Webware directory and the target working directory. If you
***************
*** 69,77 ****
"DEFAULT": "%s/Examples" % string.replace(self._webKitDir, '\\', '/'),
}
! if makeLibrary:
! self._substVals['libraryPath'] = 'sys.path.append(%s)\n' % repr(os.path.join(self._substVals['WORKDIR'], 'lib'))
else:
self._substVals['libraryPath'] = ''
self._sample = sampleContext
if sampleContext is not None:
self._substVals["DEFAULT"] = sampleContext
--- 74,91 ----
"DEFAULT": "%s/Examples" % string.replace(self._webKitDir, '\\', '/'),
}
! if libraryDirs:
! expandedLibraryDirs = []
! for dir in libraryDirs:
! dir = os.path.join(self._substVals['WORKDIR'], dir)
! expandedLibraryDirs.append(dir)
! if not os.path.exists(dir):
! os.makedirs(dir)
! open(os.path.join(dir, '__init__.py'), 'w').write('#\n')
!
! self._substVals['libraryPath'] = 'sys.path.extend(%r)\n' % expandedLibraryDirs
else:
self._substVals['libraryPath'] = ''
self._sample = sampleContext
+ self._contextDir = contextDir
if sampleContext is not None:
self._substVals["DEFAULT"] = sampleContext
***************
*** 81,85 ****
self._osType = osType
self._addCVSIgnore = addCVSIgnore
- self._makeLibrary = makeLibrary
def buildWorkDir(self):
--- 95,98 ----
***************
*** 89,95 ****
self.copyOtherFiles()
self.makeLauncherScripts()
! self.makeDefaultContext()
! if self._makeLibrary:
! self.makeLibrary()
if self._addCVSIgnore:
self.addCVSIgnore()
--- 102,107 ----
self.copyOtherFiles()
self.makeLauncherScripts()
! if self._sample is not None:
! self.makeDefaultContext()
if self._addCVSIgnore:
self.addCVSIgnore()
***************
*** 206,240 ****
Make a very simple context for the newbie user to play with.
"""
! if self._sample is not None:
! self.msg("Creating default context.")
! name = os.path.join(self._workDir, self._sample)
! if not os.path.exists(name):
! os.mkdir(name)
! name2 = os.path.join(name, 'Main.py')
open(name2, "w").write(_Main_py % self._substVals)
! name2 = os.path.join(name, '__init__.py')
open(name2, "w").write(_init_py)
! self.msg("Updating config for default context.")
! filename = os.path.join(self._workDir, "Configs", "Application.config")
! content = open(filename).readlines()
! output = open(filename, "wt")
! for line in content:
! pos = string.find(line, "##MAWD")
! if pos != -1:
! line = "\t\t\t\t\t\t\t '%(CTX)s': '%(CTX)s',\n"\
! "\t\t\t\t\t\t\t 'default': '%(CTX)s',\n"\
! % {'CTX' : self._sample}
!
output.write(line)
self.msg("\n")
- def makeLibrary(self):
- print "Creating lib/ library directory."
- os.mkdir(os.path.join(self._workDir, 'lib'))
- f = open(os.path.join(self._workDir, 'lib', '__init__.py'), 'w')
- f.write('#')
- f.close()
-
def addCVSIgnore(self):
print "Creating .cvsignore files."
--- 218,262 ----
Make a very simple context for the newbie user to play with.
"""
! self.msg("Creating default context.")
! if self._contextDir:
! contextDir = os.path.join(self._workDir, self._contextDir or self._sample)
! if contextDir.startswith(self._workDir):
! configDir = contextDir[len(self._workDir):]
! while configDir.startswith('/'):
! configDir = configDir[1:]
! else:
! configDir = contextDir
! if not os.path.exists(contextDir):
! os.makedirs(contextDir)
! name2 = os.path.join(contextDir, 'Main.py')
! if not os.path.exists(name2):
open(name2, "w").write(_Main_py % self._substVals)
! name2 = os.path.join(contextDir, '__init__.py')
! if not os.path.exists(name2):
open(name2, "w").write(_init_py)
! self.msg("Updating config for default context.")
! filename = os.path.join(self._workDir, "Configs", 'Application.config')
! content = open(filename).readlines()
! if content and content[0].strip().startswith('{'):
! isDict = 1
! else:
! isDict = 0
! output = open(filename, "wt")
! for line in content:
! pos = string.find(line, "##MAWD")
! if pos == -1:
output.write(line)
+ continue
+ if isDict:
+ output.write("\t\t\t\t\t\t\t '%(CTX)s': '%(CTXDir)s',\n"\
+ "\t\t\t\t\t\t\t 'default': '%(CTX)s',\n"\
+ % {'CTX' : self._sample,
+ 'CTXDir': configDir})
+ else:
+ output.write("Contexts[%r] = %r\n" % (self._sample, configDir))
+ output.write("Contexts['default'] = %r\n" % self._sample)
self.msg("\n")
def addCVSIgnore(self):
print "Creating .cvsignore files."
***************
*** 408,413 ****
targetDir = None
contextName = 'MyContext'
addCVSIgnore = 0
! makeLibrary = 0
args = sys.argv[1:]
# lame little command-line handler
--- 430,436 ----
targetDir = None
contextName = 'MyContext'
+ contextDir = ''
addCVSIgnore = 0
! libraryDirs = []
args = sys.argv[1:]
# lame little command-line handler
***************
*** 418,430 ****
continue
if args[0] == '-c':
! if len(args) < 2:
print __doc__
! sys.exit(1)
contextName = args[1]
args = args[2:]
continue
if args[0] in ['-l', '--library']:
! makeLibrary = 1
! args = args[1:]
continue
if not targetDir and not args[0].startswith('-'):
--- 441,466 ----
continue
if args[0] == '-c':
! if len(args) < 2 or args[1].startswith('-'):
! print "Bad option: %s" % args[0]
print __doc__
! sys.exit(2)
contextName = args[1]
args = args[2:]
continue
+ if args[0] == '-d':
+ if len(args) < 2 or args[1].startswith('-'):
+ print "Bad option: %s" % args[0]
+ print __doc__
+ sys.exit(2)
+ contextDir = args[1]
+ args = args[2:]
+ continue
if args[0] in ['-l', '--library']:
! if len(args) < 2 or args[1].startswith('-'):
! print "Bad option: %s" % args[0]
! print __doc__
! sys.exit(2)
! libraryDirs.append(args[1])
! args = args[2:]
continue
if not targetDir and not args[0].startswith('-'):
***************
*** 437,440 ****
--- 473,477 ----
sys.exit(1)
if not targetDir:
+ print "Give a target directory"
print __doc__
sys.exit(1)
***************
*** 446,451 ****
mawd = MakeAppWorkDir(webWareDir, targetDir,
sampleContext=contextName,
addCVSIgnore=addCVSIgnore,
! makeLibrary=makeLibrary)
mawd.buildWorkDir()
--- 483,489 ----
mawd = MakeAppWorkDir(webWareDir, targetDir,
sampleContext=contextName,
+ contextDir=contextDir,
addCVSIgnore=addCVSIgnore,
! libraryDirs=libraryDirs)
mawd.buildWorkDir()
|
| Thread | Author | Date |
|---|---|---|
| [Webware-checkins] CVS: Webware/bin MakeAppWorkDir.py,1.19,1.20 | Ian Bicking <ianbicking@us...> |