~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to serve-branches

  • Committer: Matt Nordhoff
  • Date: 2009-06-18 00:26:05 UTC
  • Revision ID: mnordhoff@mattnordhoff.com-20090618002605-t3y4fh1okvzenx52
Mark as compatible with bzr 1.16 and 1.17.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/env python
 
2
#
 
3
# Copyright (C) 2008, 2009 Canonical Ltd
 
4
#
2
5
# This program is free software; you can redistribute it and/or modify
3
6
# it under the terms of the GNU General Public License as published by
4
7
# the Free Software Foundation; either version 2 of the License, or
20
23
import sys
21
24
 
22
25
from bzrlib.plugin import load_plugins
 
26
from bzrlib.transport import get_transport
23
27
 
24
28
from paste import httpserver
25
29
from paste.httpexceptions import HTTPExceptionHandler, HTTPInternalServerError
26
30
from paste.translogger import TransLogger
27
31
 
28
32
from loggerhead import __version__
29
 
from loggerhead.apps.filesystem import (
30
 
    BranchesFromFileSystemRoot, UserBranchesFromFileSystemRoot)
 
33
from loggerhead.apps.transport import (
 
34
    BranchesFromTransportRoot, UserBranchesFromTransportRoot)
31
35
from loggerhead.config import LoggerheadConfig
32
36
from loggerhead.util import Reloader
33
37
from loggerhead.apps.error import ErrorHandlerApp
48
52
    else:
49
53
        path = '.'
50
54
 
51
 
    if not os.path.isdir(path):
52
 
        print "%s is not a directory" % path
53
 
        sys.exit(1)
 
55
    load_plugins()
 
56
 
 
57
    if config.get_option('allow_writes'):
 
58
        transport = get_transport(path)
 
59
    else:
 
60
        transport = get_transport('readonly+' + path)
54
61
 
55
62
    if config.get_option('trunk_dir') and not config.get_option('user_dirs'):
56
63
        print "--trunk-dir is only valid with --user-dirs"
66
73
        if not config.get_option('trunk_dir'):
67
74
            print "You didn't specify a directory for the trunk directories."
68
75
            sys.exit(1)
69
 
        app = UserBranchesFromFileSystemRoot(path, config)
 
76
        app = UserBranchesFromTransportRoot(transport, config)
70
77
    else:
71
 
        app = BranchesFromFileSystemRoot(path, config)
 
78
        app = BranchesFromTransportRoot(transport, config)
72
79
 
73
80
    # setup_logging()
74
81
    logging.basicConfig()
88
95
 
89
96
    # setup_logging() #end
90
97
 
91
 
    app = TransLogger(app, logger=logger)
92
98
    if config.get_option('profile'):
93
99
        from loggerhead.middleware.profile import LSProfMiddleware
94
100
        app = LSProfMiddleware(app)
123
129
 
124
130
    app = HTTPExceptionHandler(app)
125
131
    app = ErrorHandlerApp(app)
 
132
    app = TransLogger(app, logger=logger)
126
133
 
127
134
    if not config.get_option('user_port'):
128
135
        port = '8080'
134
141
    else:
135
142
        host = config.get_option('user_host')
136
143
 
137
 
    load_plugins()
138
 
 
139
144
    httpserver.serve(app, host=host, port=port)
140
145
 
141
146