~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to serve-branches

  • Committer: Matt Nordhoff
  • Date: 2009-05-13 14:03:48 UTC
  • mto: (389.2.2 pep8-2009-10)
  • mto: This revision was merged to the branch mainline in revision 392.
  • Revision ID: mnordhoff@mattnordhoff.com-20090513140348-yn43gztulksm62e9
Always use a tuple in string formatting

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
import sys
21
21
 
22
22
from bzrlib.plugin import load_plugins
 
23
from bzrlib.transport import get_transport
23
24
 
24
25
from paste import httpserver
25
26
from paste.httpexceptions import HTTPExceptionHandler, HTTPInternalServerError
26
27
from paste.translogger import TransLogger
27
28
 
28
29
from loggerhead import __version__
29
 
from loggerhead.apps.filesystem import (
30
 
    BranchesFromFileSystemRoot, UserBranchesFromFileSystemRoot)
 
30
from loggerhead.apps.transport import (
 
31
    BranchesFromTransportRoot, UserBranchesFromTransportRoot)
31
32
from loggerhead.config import LoggerheadConfig
32
33
from loggerhead.util import Reloader
33
34
from loggerhead.apps.error import ErrorHandlerApp
37
38
    config = LoggerheadConfig()
38
39
 
39
40
    if config.get_option('show_version'):
40
 
        print "loggerhead %s" % __version__
 
41
        print "loggerhead %s" % (__version__,)
41
42
        sys.exit(0)
42
43
 
43
44
    if config.arg_count > 1:
48
49
    else:
49
50
        path = '.'
50
51
 
51
 
    if not os.path.isdir(path):
52
 
        print "%s is not a directory" % path
53
 
        sys.exit(1)
 
52
    load_plugins()
 
53
 
 
54
    transport = get_transport(path)
54
55
 
55
56
    if config.get_option('trunk_dir') and not config.get_option('user_dirs'):
56
57
        print "--trunk-dir is only valid with --user-dirs"
66
67
        if not config.get_option('trunk_dir'):
67
68
            print "You didn't specify a directory for the trunk directories."
68
69
            sys.exit(1)
69
 
        app = UserBranchesFromFileSystemRoot(
70
 
            path, config.get_option('trunk_dir'))
 
70
        app = UserBranchesFromTransportRoot(transport, config)
71
71
    else:
72
 
        app = BranchesFromFileSystemRoot(path)
 
72
        app = BranchesFromTransportRoot(transport, config)
73
73
 
74
74
    # setup_logging()
75
75
    logging.basicConfig()
87
87
    logfile.setLevel(logging.DEBUG)
88
88
    logger.addHandler(logfile)
89
89
 
90
 
    if config.get_option('memory_profile'):
91
 
        memprofile = logging.getLogger('loggerhead-memprofile')
92
 
        memprofile.setLevel(logging.DEBUG)
93
 
        memprofile.addHandler(logging.FileHandler('loggerhead-memprofile'))
94
 
 
95
90
    # setup_logging() #end
96
91
 
97
92
    app = TransLogger(app, logger=logger)
99
94
        from loggerhead.middleware.profile import LSProfMiddleware
100
95
        app = LSProfMiddleware(app)
101
96
    if config.get_option('memory_profile'):
102
 
        from loggerhead.middleware.profile import MemoryProfileMiddleware
103
 
        app = MemoryProfileMiddleware(app)
 
97
        from dozer import Dozer
 
98
        app = Dozer(app)
104
99
 
105
100
    if not config.get_option('user_prefix'):
106
101
        prefix = '/'
140
135
    else:
141
136
        host = config.get_option('user_host')
142
137
 
143
 
    load_plugins()
144
 
 
145
138
    httpserver.serve(app, host=host, port=port)
146
139
 
147
140