Mercurial > p > roundup > code
comparison setup.py @ 1576:80519db85eac
More tweaks to the licensing to make the Debian folks happy :)
Added an "instant gratification" mode - "python setup.py demo" installs a
simple instance and runs the web server on it. Nosy is disabled.
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Mon, 07 Apr 2003 03:47:44 +0000 |
| parents | c0673f1739c3 |
| children | 070b56a0b2f6 |
comparison
equal
deleted
inserted
replaced
| 1575:f5d53a939b67 | 1576:80519db85eac |
|---|---|
| 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.44 2003-02-20 22:58:50 richard Exp $ | 19 # $Id: setup.py,v 1.45 2003-04-07 03:47:44 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 |
| 135 def buildTemplates(): | 135 def buildTemplates(): |
| 136 for template in templates: | 136 for template in templates: |
| 137 tdir = os.path.join('roundup', 'templates', template) | 137 tdir = os.path.join('roundup', 'templates', template) |
| 138 makeHtmlBase(tdir) | 138 makeHtmlBase(tdir) |
| 139 | 139 |
| 140 if __name__ == '__main__': | 140 def main(): |
| 141 # build list of scripts from their implementation modules | 141 # build list of scripts from their implementation modules |
| 142 roundup_scripts = map(scriptname, glob('roundup/scripts/[!_]*.py')) | 142 roundup_scripts = map(scriptname, glob('roundup/scripts/[!_]*.py')) |
| 143 | 143 |
| 144 # template munching | 144 # template munching |
| 145 templates = map(os.path.basename, filter(isTemplateDir, | 145 templates = map(os.path.basename, filter(isTemplateDir, |
| 216 scripts = roundup_scripts, | 216 scripts = roundup_scripts, |
| 217 | 217 |
| 218 data_files = installdatafiles | 218 data_files = installdatafiles |
| 219 ) | 219 ) |
| 220 | 220 |
| 221 def install_demo(): | |
| 222 ''' Install a demo server for users to play with for instant gratification. | |
| 223 | |
| 224 Sets up the web service on localhost port 8080. Disables nosy lists. | |
| 225 ''' | |
| 226 import shutil, socket, errno, BaseHTTPServer | |
| 227 | |
| 228 # create the instance | |
| 229 home = os.path.abspath('demo') | |
| 230 try: | |
| 231 shutil.rmtree(home) | |
| 232 except os.error, error: | |
| 233 if error.errno != errno.ENOENT: | |
| 234 raise | |
| 235 from roundup import init, instance, password | |
| 236 init.install(home, 'classic') | |
| 237 # don't have email flying around | |
| 238 os.remove(os.path.join(home, 'detectors', 'nosyreaction.py')) | |
| 239 init.write_select_db(home, 'anydbm') | |
| 240 | |
| 241 # figure basic params for server | |
| 242 hostname = socket.gethostname() | |
| 243 port = 8080 | |
| 244 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
| 245 s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) | |
| 246 while 1: | |
| 247 print 'Trying to set up web server on port %d ...'%port, | |
| 248 try: | |
| 249 s.bind((hostname, port)) | |
| 250 except socket.error, error: | |
| 251 if error.errno != errno.EADDRINUSE: | |
| 252 raise | |
| 253 print 'already in use.' | |
| 254 port += 100 | |
| 255 else: | |
| 256 print 'should be ok.' | |
| 257 break | |
| 258 url = 'http://%s:%s/demo/'%(hostname, port) | |
| 259 | |
| 260 # write the config | |
| 261 f = open(os.path.join(home, 'config.py'), 'r') | |
| 262 s = f.read().replace('http://tracker.example/cgi-bin/roundup.cgi/bugs/', | |
| 263 url) | |
| 264 f.close() | |
| 265 f = open(os.path.join(home, 'config.py'), 'w') | |
| 266 f.write(s) | |
| 267 f.close() | |
| 268 | |
| 269 # initialise the database | |
| 270 init.initialise(home, 'admin') | |
| 271 | |
| 272 # add the "demo" user | |
| 273 tracker = instance.open(home) | |
| 274 db = tracker.open('admin') | |
| 275 db.user.create(username='demo', password=password.Password('demo'), | |
| 276 realname='Demo User', roles='User') | |
| 277 db.commit() | |
| 278 db.close() | |
| 279 | |
| 280 # ok, so start up the server | |
| 281 from roundup.scripts.roundup_server import RoundupRequestHandler | |
| 282 RoundupRequestHandler.TRACKER_HOMES = {'demo': home} | |
| 283 httpd = BaseHTTPServer.HTTPServer((hostname, port), RoundupRequestHandler) | |
| 284 print 'Server running - connect to:\n %s'%url | |
| 285 print 'You may log in as "demo"/"demo" or "admin"/"admin".' | |
| 286 try: | |
| 287 httpd.serve_forever() | |
| 288 except KeyboardInterrupt: | |
| 289 print 'Keyboard Interrupt: exiting' | |
| 290 | |
| 291 if __name__ == '__main__': | |
| 292 if len(sys.argv) > 1 and sys.argv[1] == 'demo': | |
| 293 install_demo() | |
| 294 else: | |
| 295 main() | |
| 296 | |
| 221 # vim: set filetype=python ts=4 sw=4 et si | 297 # vim: set filetype=python ts=4 sw=4 et si |
