Mercurial > p > roundup > code
comparison setup.py @ 1640:d0b29215aa44
pre-release stuff
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Fri, 09 May 2003 05:04:34 +0000 |
| parents | 7034b61e9d9e |
| children | 41dbd406a79c |
comparison
equal
deleted
inserted
replaced
| 1639:aa4a2b96a472 | 1640:d0b29215aa44 |
|---|---|
| 14 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | 14 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 15 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" | 15 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" |
| 16 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, | 16 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, |
| 17 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. | 17 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
| 18 # | 18 # |
| 19 # $Id: setup.py,v 1.50 2003-04-25 02:09:20 richard Exp $ | 19 # $Id: setup.py,v 1.51 2003-05-09 05:04:33 richard Exp $ |
| 20 | 20 |
| 21 from distutils.core import setup, Extension | 21 from distutils.core import setup, Extension |
| 22 from distutils.util import get_platform | 22 from distutils.util import get_platform |
| 23 from distutils.command.build_scripts import build_scripts | 23 from distutils.command.build_scripts import build_scripts |
| 24 | 24 |
| 209 scripts = roundup_scripts, | 209 scripts = roundup_scripts, |
| 210 | 210 |
| 211 data_files = installdatafiles | 211 data_files = installdatafiles |
| 212 ) | 212 ) |
| 213 | 213 |
| 214 def install_demo(): | |
| 215 ''' Install a demo server for users to play with for instant gratification. | |
| 216 | |
| 217 Sets up the web service on localhost port 8080. Disables nosy lists. | |
| 218 ''' | |
| 219 import shutil, socket, errno, BaseHTTPServer | |
| 220 | |
| 221 # create the instance | |
| 222 home = os.path.abspath('demo') | |
| 223 try: | |
| 224 shutil.rmtree(home) | |
| 225 except os.error, error: | |
| 226 if error.errno != errno.ENOENT: | |
| 227 raise | |
| 228 from roundup import init, instance, password | |
| 229 init.install(home, os.path.join('templates', 'classic')) | |
| 230 # don't have email flying around | |
| 231 os.remove(os.path.join(home, 'detectors', 'nosyreaction.py')) | |
| 232 init.write_select_db(home, 'anydbm') | |
| 233 | |
| 234 # figure basic params for server | |
| 235 hostname = socket.gethostname() | |
| 236 # pick a fairly odd, random port | |
| 237 port = 8917 | |
| 238 while 1: | |
| 239 print 'Trying to set up web server on port %d ...'%port, | |
| 240 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
| 241 s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) | |
| 242 try: | |
| 243 s.connect((hostname, port)) | |
| 244 except socket.error, e: | |
| 245 if not hasattr(e, 'args') or e.args[0] != errno.ECONNREFUSED: | |
| 246 raise | |
| 247 print 'should be ok.' | |
| 248 break | |
| 249 else: | |
| 250 s.close() | |
| 251 print 'already in use.' | |
| 252 port += 100 | |
| 253 url = 'http://%s:%s/demo/'%(hostname, port) | |
| 254 | |
| 255 # write the config | |
| 256 f = open(os.path.join(home, 'config.py'), 'r') | |
| 257 s = f.read().replace('http://tracker.example/cgi-bin/roundup.cgi/bugs/', | |
| 258 url) | |
| 259 f.close() | |
| 260 f = open(os.path.join(home, 'config.py'), 'w') | |
| 261 f.write(s) | |
| 262 f.close() | |
| 263 | |
| 264 # initialise the database | |
| 265 init.initialise(home, 'admin') | |
| 266 | |
| 267 # add the "demo" user | |
| 268 tracker = instance.open(home) | |
| 269 db = tracker.open('admin') | |
| 270 db.user.create(username='demo', password=password.Password('demo'), | |
| 271 realname='Demo User', roles='User') | |
| 272 db.commit() | |
| 273 db.close() | |
| 274 | |
| 275 # ok, so start up the server | |
| 276 from roundup.scripts.roundup_server import RoundupRequestHandler | |
| 277 RoundupRequestHandler.TRACKER_HOMES = {'demo': home} | |
| 278 httpd = BaseHTTPServer.HTTPServer((hostname, port), RoundupRequestHandler) | |
| 279 print 'Server running - connect to:\n %s'%url | |
| 280 print 'You may log in as "demo"/"demo" or "admin"/"admin".' | |
| 281 print 'Hit Control-C to stop the server.' | |
| 282 try: | |
| 283 httpd.serve_forever() | |
| 284 except KeyboardInterrupt: | |
| 285 print 'Keyboard Interrupt: exiting' | |
| 286 | |
| 287 if __name__ == '__main__': | 214 if __name__ == '__main__': |
| 288 if len(sys.argv) > 1 and sys.argv[1] == 'demo': | 215 main() |
| 289 install_demo() | |
| 290 else: | |
| 291 main() | |
| 292 | 216 |
| 293 # vim: set filetype=python ts=4 sw=4 et si | 217 # vim: set filetype=python ts=4 sw=4 et si |
