annotate roundup/init.py @ 2770:cdf6787ffeda

implement getopt(). support config file paths as well as directory paths for loading. UserConfig: defaults were added to all config sections. filter them out.
author Alexander Smishlajev <a1s@users.sourceforge.net>
date Sun, 17 Oct 2004 17:35:32 +0000
parents b2cd472919c8
children 22c459281026
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
213
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 208
diff changeset
1 #
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 208
diff changeset
2 # Copyright (c) 2001 Bizar Software Pty Ltd (http://www.bizarsoftware.com.au/)
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 208
diff changeset
3 # This module is free software, and you may redistribute it and/or modify
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 208
diff changeset
4 # under the same terms as Python, so long as this copyright message and
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 208
diff changeset
5 # disclaimer are retained in their original form.
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 208
diff changeset
6 #
214
18134bffab37 stupid typo
Richard Jones <richard@users.sourceforge.net>
parents: 213
diff changeset
7 # IN NO EVENT SHALL BIZAR SOFTWARE PTY LTD BE LIABLE TO ANY PARTY FOR
213
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 208
diff changeset
8 # DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 208
diff changeset
9 # OUT OF THE USE OF THIS CODE, EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 208
diff changeset
10 # POSSIBILITY OF SUCH DAMAGE.
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 208
diff changeset
11 #
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 208
diff changeset
12 # BIZAR SOFTWARE PTY LTD SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 208
diff changeset
13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 208
diff changeset
14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS"
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 208
diff changeset
15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 208
diff changeset
16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
2766
b2cd472919c8 if there is no config installed from the template, write default config text;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2700
diff changeset
17 #
b2cd472919c8 if there is no config installed from the template, write default config text;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2700
diff changeset
18 # $Id: init.py,v 1.32 2004-10-16 14:45:12 a1s Exp $
406
bdc2ea127ae9 Added module docstrings to all modules.
Jürgen Hermann <jhermann@users.sourceforge.net>
parents: 388
diff changeset
19
2005
fc52d57c6c3e documentation cleanup
Richard Jones <richard@users.sourceforge.net>
parents: 1916
diff changeset
20 """Init (create) a roundup instance.
406
bdc2ea127ae9 Added module docstrings to all modules.
Jürgen Hermann <jhermann@users.sourceforge.net>
parents: 388
diff changeset
21 """
2005
fc52d57c6c3e documentation cleanup
Richard Jones <richard@users.sourceforge.net>
parents: 1916
diff changeset
22 __docformat__ = 'restructuredtext'
26
c7c14960f413 Final commit of Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents: 25
diff changeset
23
1916
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
24 import os, sys, errno, rfc822
204
c1461733cbf9 Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents: 201
diff changeset
25
2766
b2cd472919c8 if there is no config installed from the template, write default config text;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2700
diff changeset
26 import roundup.instance
b2cd472919c8 if there is no config installed from the template, write default config text;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2700
diff changeset
27 from roundup import install_util, password
b2cd472919c8 if there is no config installed from the template, write default config text;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2700
diff changeset
28 from roundup.configuration import CoreConfig
25
4cf1daf2f2eb More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
29
4cf1daf2f2eb More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
30 def copytree(src, dst, symlinks=0):
388
2d92f93072f9 Code using copyDigestedFile() that passes unit tests
Jürgen Hermann <jhermann@users.sourceforge.net>
parents: 270
diff changeset
31 """Recursively copy a directory tree using copyDigestedFile().
25
4cf1daf2f2eb More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
32
4cf1daf2f2eb More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
33 The destination directory os allowed to exist.
4cf1daf2f2eb More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
34
4cf1daf2f2eb More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
35 If the optional symlinks flag is true, symbolic links in the
4cf1daf2f2eb More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
36 source tree result in symbolic links in the destination tree; if
4cf1daf2f2eb More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
37 it is false, the contents of the files pointed to by symbolic
4cf1daf2f2eb More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
38 links are copied.
4cf1daf2f2eb More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
39
1103
db787cef1385 handled some XXXs
Richard Jones <richard@users.sourceforge.net>
parents: 1085
diff changeset
40 This was copied from shutil.py in std lib.
25
4cf1daf2f2eb More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
41 """
4cf1daf2f2eb More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
42 names = os.listdir(src)
4cf1daf2f2eb More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
43 try:
4cf1daf2f2eb More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
44 os.mkdir(dst)
4cf1daf2f2eb More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
45 except OSError, error:
113
2ab86442799a Replaced errno integers with their module values.
Richard Jones <richard@users.sourceforge.net>
parents: 70
diff changeset
46 if error.errno != errno.EEXIST: raise
25
4cf1daf2f2eb More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
47 for name in names:
4cf1daf2f2eb More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
48 srcname = os.path.join(src, name)
4cf1daf2f2eb More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
49 dstname = os.path.join(dst, name)
4cf1daf2f2eb More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
50 if symlinks and os.path.islink(srcname):
4cf1daf2f2eb More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
51 linkto = os.readlink(srcname)
4cf1daf2f2eb More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
52 os.symlink(linkto, dstname)
4cf1daf2f2eb More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
53 elif os.path.isdir(srcname):
4cf1daf2f2eb More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
54 copytree(srcname, dstname, symlinks)
4cf1daf2f2eb More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
55 else:
388
2d92f93072f9 Code using copyDigestedFile() that passes unit tests
Jürgen Hermann <jhermann@users.sourceforge.net>
parents: 270
diff changeset
56 install_util.copyDigestedFile(srcname, dstname)
25
4cf1daf2f2eb More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
57
1467
378081f066cc registration is now a two-step process with confirmation from the
Richard Jones <richard@users.sourceforge.net>
parents: 1103
diff changeset
58 def install(instance_home, template):
738
7e093cbaaa98 split instance initialisation into two steps...
Richard Jones <richard@users.sourceforge.net>
parents: 406
diff changeset
59 '''Install an instance using the named template and backend.
208
1894a28a1e66 Added documentation.
Richard Jones <richard@users.sourceforge.net>
parents: 204
diff changeset
60
2005
fc52d57c6c3e documentation cleanup
Richard Jones <richard@users.sourceforge.net>
parents: 1916
diff changeset
61 'instance_home'
fc52d57c6c3e documentation cleanup
Richard Jones <richard@users.sourceforge.net>
parents: 1916
diff changeset
62 the directory to place the instance data in
fc52d57c6c3e documentation cleanup
Richard Jones <richard@users.sourceforge.net>
parents: 1916
diff changeset
63 'template'
fc52d57c6c3e documentation cleanup
Richard Jones <richard@users.sourceforge.net>
parents: 1916
diff changeset
64 the directory holding the template to use in creating the instance data
208
1894a28a1e66 Added documentation.
Richard Jones <richard@users.sourceforge.net>
parents: 204
diff changeset
65
1894a28a1e66 Added documentation.
Richard Jones <richard@users.sourceforge.net>
parents: 204
diff changeset
66 The instance_home directory will be created using the files found in
1894a28a1e66 Added documentation.
Richard Jones <richard@users.sourceforge.net>
parents: 204
diff changeset
67 the named template (roundup.templates.<name>). A standard instance_home
1894a28a1e66 Added documentation.
Richard Jones <richard@users.sourceforge.net>
parents: 204
diff changeset
68 contains:
1894a28a1e66 Added documentation.
Richard Jones <richard@users.sourceforge.net>
parents: 204
diff changeset
69
2005
fc52d57c6c3e documentation cleanup
Richard Jones <richard@users.sourceforge.net>
parents: 1916
diff changeset
70 config.py
fc52d57c6c3e documentation cleanup
Richard Jones <richard@users.sourceforge.net>
parents: 1916
diff changeset
71 simple configuration of things like the email address for the
fc52d57c6c3e documentation cleanup
Richard Jones <richard@users.sourceforge.net>
parents: 1916
diff changeset
72 mail gateway, the mail domain, the mail host, ...
fc52d57c6c3e documentation cleanup
Richard Jones <richard@users.sourceforge.net>
parents: 1916
diff changeset
73 dbinit.py and select_db.py
fc52d57c6c3e documentation cleanup
Richard Jones <richard@users.sourceforge.net>
parents: 1916
diff changeset
74 defines the schema for the hyperdatabase and indicates which
fc52d57c6c3e documentation cleanup
Richard Jones <richard@users.sourceforge.net>
parents: 1916
diff changeset
75 backend to use.
fc52d57c6c3e documentation cleanup
Richard Jones <richard@users.sourceforge.net>
parents: 1916
diff changeset
76 interfaces.py
fc52d57c6c3e documentation cleanup
Richard Jones <richard@users.sourceforge.net>
parents: 1916
diff changeset
77 defines the CGI Client and mail gateway MailGW classes that are
fc52d57c6c3e documentation cleanup
Richard Jones <richard@users.sourceforge.net>
parents: 1916
diff changeset
78 used by roundup.cgi, roundup-server and roundup-mailgw.
fc52d57c6c3e documentation cleanup
Richard Jones <richard@users.sourceforge.net>
parents: 1916
diff changeset
79 __init__.py
fc52d57c6c3e documentation cleanup
Richard Jones <richard@users.sourceforge.net>
parents: 1916
diff changeset
80 ties together all the instance information into one interface
fc52d57c6c3e documentation cleanup
Richard Jones <richard@users.sourceforge.net>
parents: 1916
diff changeset
81 db/
fc52d57c6c3e documentation cleanup
Richard Jones <richard@users.sourceforge.net>
parents: 1916
diff changeset
82 the actual database that stores the instance's data
fc52d57c6c3e documentation cleanup
Richard Jones <richard@users.sourceforge.net>
parents: 1916
diff changeset
83 html/
fc52d57c6c3e documentation cleanup
Richard Jones <richard@users.sourceforge.net>
parents: 1916
diff changeset
84 the html templates that are used by the CGI Client
fc52d57c6c3e documentation cleanup
Richard Jones <richard@users.sourceforge.net>
parents: 1916
diff changeset
85 detectors/
fc52d57c6c3e documentation cleanup
Richard Jones <richard@users.sourceforge.net>
parents: 1916
diff changeset
86 the auditor and reactor modules for this instance
2700
Richard Jones <richard@users.sourceforge.net>
parents: 2633
diff changeset
87 extensions/
Richard Jones <richard@users.sourceforge.net>
parents: 2633
diff changeset
88 code extensions to Roundup
25
4cf1daf2f2eb More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
89 '''
1591
21312a7564fd moving templates around
Richard Jones <richard@users.sourceforge.net>
parents: 1467
diff changeset
90 # At the moment, it's just a copy
190
996eaf90c01e Instance import now imports the instance using imp.load_module...
Richard Jones <richard@users.sourceforge.net>
parents: 127
diff changeset
91 copytree(template, instance_home)
25
4cf1daf2f2eb More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
92
1916
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
93 # rename the tempate in the TEMPLATE-INFO.txt file
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
94 ti = loadTemplateInfo(instance_home)
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
95 ti['name'] = ti['name'] + '-' + os.path.split(instance_home)[1]
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
96 saveTemplateInfo(instance_home, ti)
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
97
2766
b2cd472919c8 if there is no config installed from the template, write default config text;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2700
diff changeset
98 # if there is no config.ini or old-style config.py
b2cd472919c8 if there is no config installed from the template, write default config text;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2700
diff changeset
99 # installed from the template, write default config text
b2cd472919c8 if there is no config installed from the template, write default config text;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2700
diff changeset
100 config_ini_file = os.path.join(instance_home, CoreConfig.INI_FILE)
b2cd472919c8 if there is no config installed from the template, write default config text;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2700
diff changeset
101 if not (os.path.isfile(config_ini_file)
b2cd472919c8 if there is no config installed from the template, write default config text;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2700
diff changeset
102 or os.path.isfile(os.path.join(instance_home, 'config.py'))
b2cd472919c8 if there is no config installed from the template, write default config text;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2700
diff changeset
103 ):
b2cd472919c8 if there is no config installed from the template, write default config text;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2700
diff changeset
104 config = CoreConfig()
b2cd472919c8 if there is no config installed from the template, write default config text;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2700
diff changeset
105 config.save(config_ini_file)
b2cd472919c8 if there is no config installed from the template, write default config text;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2700
diff changeset
106
1916
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
107
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
108 def listTemplates(dir):
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
109 ''' List all the Roundup template directories in a given directory.
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
110
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
111 Find all the dirs that contain a TEMPLATE-INFO.txt and parse it.
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
112
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
113 Return a list of dicts of info about the templates.
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
114 '''
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
115 ret = {}
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
116 for idir in os.listdir(dir):
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
117 idir = os.path.join(dir, idir)
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
118 ti = loadTemplateInfo(idir)
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
119 if ti:
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
120 ret[ti['name']] = ti
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
121 return ret
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
122
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
123 def loadTemplateInfo(dir):
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
124 ''' Attempt to load a Roundup template from the indicated directory.
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
125
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
126 Return None if there's no template, otherwise a template info
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
127 dictionary.
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
128 '''
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
129 ti = os.path.join(dir, 'TEMPLATE-INFO.txt')
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
130 if not os.path.exists(ti):
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
131 return None
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
132
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
133 # load up the template's information
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
134 f = open(ti)
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
135 try:
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
136 m = rfc822.Message(open(ti))
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
137 ti = {}
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
138 ti['name'] = m['name']
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
139 ti['description'] = m['description']
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
140 ti['intended-for'] = m['intended-for']
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
141 ti['path'] = dir
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
142 finally:
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
143 f.close()
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
144 return ti
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
145
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
146 def writeHeader(name, value):
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
147 ''' Write an rfc822-compatible header line, making it wrap reasonably
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
148 '''
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
149 out = [name.capitalize() + ':']
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
150 n = len(out[0])
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
151 for word in value.split():
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
152 if len(word) + n > 74:
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
153 out.append('\n')
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
154 n = 0
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
155 out.append(' ' + word)
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
156 n += len(out[-1])
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
157 return ''.join(out) + '\n'
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
158
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
159 def saveTemplateInfo(dir, info):
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
160 ''' Save the template info (dict of values) to the TEMPLATE-INFO.txt
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
161 file in the indicated directory.
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
162 '''
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
163 ti = os.path.join(dir, 'TEMPLATE-INFO.txt')
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
164 f = open(ti, 'w')
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
165 try:
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
166 for name in 'name description intended-for path'.split():
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
167 f.write(writeHeader(name, info[name]))
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
168 finally:
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
169 f.close()
d157b9b56ebf implemented munging of template name for installed trackers
Richard Jones <richard@users.sourceforge.net>
parents: 1728
diff changeset
170
1467
378081f066cc registration is now a two-step process with confirmation from the
Richard Jones <richard@users.sourceforge.net>
parents: 1103
diff changeset
171 def write_select_db(instance_home, backend):
378081f066cc registration is now a two-step process with confirmation from the
Richard Jones <richard@users.sourceforge.net>
parents: 1103
diff changeset
172 ''' Write the file that selects the backend for the tracker
378081f066cc registration is now a two-step process with confirmation from the
Richard Jones <richard@users.sourceforge.net>
parents: 1103
diff changeset
173 '''
2633
a9e1fff1e793 I thought I committed this last night. Ho hum.
Richard Jones <richard@users.sourceforge.net>
parents: 2005
diff changeset
174 dbdir = os.path.join(instance_home, 'db')
a9e1fff1e793 I thought I committed this last night. Ho hum.
Richard Jones <richard@users.sourceforge.net>
parents: 2005
diff changeset
175 if not os.path.exists(dbdir):
a9e1fff1e793 I thought I committed this last night. Ho hum.
Richard Jones <richard@users.sourceforge.net>
parents: 2005
diff changeset
176 os.makedirs(dbdir)
a9e1fff1e793 I thought I committed this last night. Ho hum.
Richard Jones <richard@users.sourceforge.net>
parents: 2005
diff changeset
177 f = open(os.path.join(dbdir, 'backend_name'), 'w')
a9e1fff1e793 I thought I committed this last night. Ho hum.
Richard Jones <richard@users.sourceforge.net>
parents: 2005
diff changeset
178 f.write(backend+'\n')
a9e1fff1e793 I thought I committed this last night. Ho hum.
Richard Jones <richard@users.sourceforge.net>
parents: 2005
diff changeset
179 f.close()
51
3a7e5515c1bd ok, so now "./roundup-admin init" will ask questions...
Richard Jones <richard@users.sourceforge.net>
parents: 26
diff changeset
180
738
7e093cbaaa98 split instance initialisation into two steps...
Richard Jones <richard@users.sourceforge.net>
parents: 406
diff changeset
181
25
4cf1daf2f2eb More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
182
2766
b2cd472919c8 if there is no config installed from the template, write default config text;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2700
diff changeset
183 # vim: set filetype=python sts=4 sw=4 et si :

Roundup Issue Tracker: http://roundup-tracker.org/