Skip to content

Commit 4ee7800

Browse files
committed
demo: Make tracker home configurable.
1 parent 4e9b415 commit 4ee7800

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

demo.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
from roundup import configuration
1414
from 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+
1619
def 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

103106
def 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
116119
Demo tracker is set up to be accessed by localhost browser. If you
117120
run 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"
119122
option in section "[tracker]", save the file, then re-run the demo
120123
program. 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+
134140
Options:
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

141147
def 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

Comments
 (0)