22#
33# Copyright (c) 2003 Richard Jones ([email protected] ) 44#
5- # $Id: demo.py,v 1.8 2004-03-24 03:07:51 richard Exp $
5+ # $Id: demo.py,v 1.9 2004-03-24 05:39:47 richard Exp $
66
77import sys , os , string , re , urlparse
88import shutil , socket , errno , BaseHTTPServer
99from glob import glob
1010
11- def install_demo (home ):
11+ def install_demo (home , backend ):
1212 # create the instance
1313 if os .path .exists (home ):
1414 shutil .rmtree (home )
@@ -21,7 +21,7 @@ def install_demo(home):
2121 except os .error , error :
2222 if error .errno != errno .ENOENT :
2323 raise
24- init .write_select_db (home , 'mysql' )
24+ init .write_select_db (home , backend )
2525
2626 # figure basic params for server
2727 hostname = socket .gethostname ()
@@ -49,12 +49,14 @@ def install_demo(home):
4949 s = f .read ().replace ('http://tracker.example/cgi-bin/roundup.cgi/bugs/' ,
5050 url )
5151 f .close ()
52+ # DB connection stuff for mysql and postgresql
5253 s = s + """
5354MYSQL_DBHOST = 'localhost'
5455MYSQL_DBUSER = 'rounduptest'
5556MYSQL_DBPASSWORD = 'rounduptest'
5657MYSQL_DBNAME = 'rounduptest'
5758MYSQL_DATABASE = (MYSQL_DBHOST, MYSQL_DBUSER, MYSQL_DBPASSWORD, MYSQL_DBNAME)
59+ POSTGRESQL_DATABASE = {'database': 'rounduptest'}
5860"""
5961 f = open (os .path .join (home , 'config.py' ), 'w' )
6062 f .write (s )
@@ -77,8 +79,11 @@ def run_demo():
7779 Sets up the web service on localhost. Disables nosy lists.
7880 '''
7981 home = os .path .abspath ('demo' )
82+ backend = 'anydbm'
8083 if not os .path .exists (home ) or sys .argv [- 1 ] == 'nuke' :
81- install_demo (home )
84+ if len (sys .argv ) > 2 :
85+ backend = sys .argv [1 ]
86+ install_demo (home , backend )
8287
8388 f = open (os .path .join (home , 'config.py' ), 'r' )
8489 url = re .search (r'^TRACKER_WEB\s*=\s*[\'"](http.+/)[\'"]$' , f .read (),
0 commit comments