ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/WEBTOOLS/cmsWeb.py
Revision: 1.4
Committed: Fri May 18 08:47:48 2007 UTC (17 years, 11 months ago) by eulisse
Content type: text/x-python
Branch: MAIN
CVS Tags: SiteDB_SM_Nightly_070108, V01-02-04, V01-02-03, V01-02-02, V01-02-01, V01-02-00, V01-00-12, PHEDEX-WebSite-2_5_3_1
Changes since 1.3: +9 -2 lines
Log Message:
* --base-url option now gets trailing "/" removed.

File Contents

# User Rev Content
1 eulisse 1.1 #!/usr/bin/env python
2     from Framework import BonsaiServer
3 eulisse 1.2 from Framework import Context
4     from optparse import OptionParser
5     from Framework import CmdLineArgs
6 eulisse 1.1
7 eulisse 1.3 class Cfg:
8     def __init__ (self):
9     # TODO: make it a property.
10     self.installRoot = __file__.rsplit ("/", 1)[0]
11    
12 eulisse 1.4
13 eulisse 1.1 if __name__ == '__main__':
14 eulisse 1.2 context = Context ()
15     context.addService (OptionParser ())
16     context.OptionParser ().add_option ("--profile",
17     help="start server in profiler mode",
18     default=False,
19     action="store_true",
20     dest="profile")
21 eulisse 1.4 def stripTrailingSlash (option, opt_str, value, parser, *args, **kwargs):
22     setattr(parser.values, option.dest, value.rstrip ("/"))
23    
24 eulisse 1.2 context.OptionParser ().add_option ("--base-url",
25     help="Base URL for the server (for usage behind a proxy).",
26     default="http://localhost:8030",
27 eulisse 1.4 dest="baseUrl",
28     action="callback",
29     callback=stripTrailingSlash,
30     type="str",
31     nargs=1)
32 eulisse 1.2
33     app = BonsaiServer (context)
34    
35     opts, args = context.OptionParser ().parse_args ()
36     context.addService (CmdLineArgs (context.OptionParser ()))
37 eulisse 1.3 context.addService (Cfg ())
38 eulisse 1.2
39     if opts.profile:
40     import pstats
41     try:
42     import cProfile as profile
43     except ImportError:
44     import profile
45     profile.run ('app.start ()', 'bonsaiProfiler')
46    
47     p = pstats.Stats('bonsaiProfiler')
48     p.strip_dirs().sort_stats(-1).print_stats()
49     else:
50     app.start ()