~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to serve-branches

  • Committer: Martin Albisetti
  • Date: 2008-08-20 23:37:59 UTC
  • Revision ID: argentina@gmail.com-20080820233759-y57h48eon7kig1fh
Tweak footer to look better.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
from loggerhead import __version__
29
29
from loggerhead.apps.filesystem import (
30
30
    BranchesFromFileSystemRoot, UserBranchesFromFileSystemRoot)
31
 
from loggerhead.util import Reloader
32
31
 
33
32
 
34
33
def command_line_parser():
41
40
                      help="Serve user directories as ~user.")
42
41
    parser.add_option("--trunk-dir", metavar="DIR",
43
42
                      help="The directory that contains the trunk branches.")
44
 
    parser.add_option("--port", dest="user_port",
45
 
                      help="Port Loggerhead should listen on (defaults to 8080).")
46
 
    parser.add_option("--host", dest="user_host",
47
 
                      help="Host Loggerhead should listen on.")
48
 
    parser.add_option("--prefix", dest="user_prefix",
49
 
                      help="Specify host prefix.")
50
 
    parser.add_option("--reload", action="store_true", dest="reload",
51
 
                      help="Restarts the application when changing python"
52
 
                           " files. Only used for development purposes.")
53
43
    parser.add_option("--version", action="store_true", dest="show_version",
54
44
                      help="Print the software version and exit")
55
45
    return parser
81
71
    if options.trunk_dir and not options.user_dirs:
82
72
        print "--trunk-dir is only valid with --user-dirs"
83
73
        sys.exit(1)
84
 
        
85
 
    if options.reload:
86
 
        if Reloader.is_installed():
87
 
            Reloader.install()
88
 
        else:
89
 
            return Reloader.restart_with_reloader()
90
74
 
91
75
    if options.user_dirs:
92
76
        if not options.trunk_dir:
98
82
    app = HTTPExceptionHandler(app)
99
83
    app = TransLogger(app)
100
84
 
101
 
    if not options.user_prefix:
102
 
        prefix = '/'
103
 
    else:
104
 
        prefix = options.user_prefix
105
 
 
106
85
    try:
107
86
        from paste.deploy.config import PrefixMiddleware
108
87
    except ImportError:
109
88
        pass
110
89
    else:
111
 
        app = PrefixMiddleware(app, prefix=prefix)
112
 
    
113
 
    if not options.user_port:
114
 
        port = '8080'
115
 
    else:
116
 
        port = options.user_port
117
 
 
118
 
    if not options.user_host:
119
 
        host = '0.0.0.0'
120
 
    else:
121
 
        host = options.user_host
122
 
 
123
 
    httpserver.serve(app, host=host, port=port)
 
90
        app = PrefixMiddleware(app)
 
91
 
 
92
    httpserver.serve(app, host='0.0.0.0', port='8080')
124
93
 
125
94
 
126
95
if __name__ == "__main__":