1313from roundup import configuration
1414from roundup .scripts import roundup_server
1515
16+ # Path where demo instance files will be stored
17+ TRACKER_HOME = os .path .join (os .path .dirname (__file__ ), 'demo' )
18+
1619def install_demo (home , backend , template ):
1720 """Install a demo tracker
1821
@@ -101,7 +104,7 @@ def install_demo(home, backend, template):
101104 db .close ()
102105
103106def run_demo (home ):
104- """Run the demo tracker installed in ``home``"""
107+ """Run the demo tracker instance from its ``home`` directory """
105108 cfg = configuration .CoreConfig (home )
106109 url = cfg ["TRACKER_WEB" ]
107110 hostname , port = urlparse .urlparse (url )[1 ].split (':' )
@@ -115,11 +118,11 @@ def run_demo(home):
115118
116119Demo tracker is set up to be accessed by localhost browser. If you
117120run demo on a server host, please stop the demo, open file
118- "demo /config.ini" with your editor, change the host name in the "web"
121+ "%(datadir)s /config.ini" with your editor, change the host name in the "web"
119122option in section "[tracker]", save the file, then re-run the demo
120123program. If you want to change backend types, you must use "nuke".
121124
122- ''' % dict (url = url , script = sys .argv [0 ])
125+ ''' % dict (url = url , script = sys .argv [0 ], datadir = TRACKER_HOME )
123126
124127 # disable command line processing in roundup_server
125128 sys .argv = sys .argv [:1 ] + ['-p' , str (port ), 'demo=' + home ]
@@ -131,11 +134,14 @@ def usage(msg = ''):
131134 if msg : print msg
132135 print 'Usage: %s [options] [nuke]' % sys .argv [0 ]
133136 print """
137+ Run a demo server. Config and database files are created
138+ in %(datadir)s/ subdirectory of %(script)s dir.
139+
134140Options:
135141 -h -- print this help message
136142 -t template -- specify the tracker template to use
137143 -b backend -- specify the database backend to use
138- """
144+ """ % dict ( script = sys . argv [ 0 ], datadir = TRACKER_HOME )
139145
140146
141147def main ():
@@ -154,7 +160,7 @@ def main():
154160 usage ()
155161 return 0
156162
157- home = os .path .abspath ('demo' )
163+ home = os .path .abspath (TRACKER_HOME )
158164 nuke = args and args [0 ] == 'nuke'
159165 if not os .path .exists (home ) or nuke :
160166 backend = 'anydbm'
@@ -169,6 +175,7 @@ def main():
169175 usage ()
170176 return 1
171177
178+ print "Initializing demo instance in:\n %s" % home
172179 install_demo (home , backend , template )
173180 elif opts :
174181 print "Error: Arguments are not allowed when running an existing demo."
0 commit comments