Correction crash
[auf_roundup.git] / build / lib / roundup / scripts / roundup_demo.py
1 #! /usr/bin/env python
2 #
3 # Copyright 2004 Richard Jones (richard@mechanicalcat.net)
4 #
5
6 import sys
7
8 from roundup import admin, configuration, demo, instance
9 from roundup.i18n import _
10
11 DEFAULT_HOME = './demo'
12 DEFAULT_TEMPLATE = 'classic'
13
14 def run():
15 home = DEFAULT_HOME
16 template = DEFAULT_TEMPLATE
17 nuke = sys.argv[-1] == 'nuke'
18 # if there is no tracker in home, force nuke
19 try:
20 instance.open(home)
21 except configuration.NoConfigError:
22 nuke = 1
23 # if we are to create the tracker, prompt for home
24 if nuke:
25 if len(sys.argv) > 2:
26 backend = sys.argv[-2]
27 else:
28 backend = 'anydbm'
29 # FIXME: i'd like to have an option to abort the tracker creation
30 # say, by entering a single dot. but i cannot think of
31 # appropriate prompt for that.
32 home = raw_input(
33 _('Enter directory path to create demo tracker [%s]: ') % home)
34 if not home:
35 home = DEFAULT_HOME
36 templates = admin.AdminTool().listTemplates().keys()
37 template = raw_input(
38 _('Enter tracker template to use (one of (%s)) [%s]: ') %
39 (','.join(templates),template))
40 if not template:
41 template = DEFAULT_TEMPLATE
42 # install
43 demo.install_demo(home, backend,
44 admin.AdminTool().listTemplates()[template]['path'])
45 # run
46 demo.run_demo(home)
47
48 if __name__ == '__main__':
49 run()
50
51 # vim: set et sts=4 sw=4 :