~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to serve-branches

  • Committer: Martin Albisetti
  • Date: 2009-06-01 00:20:43 UTC
  • mfrom: (352.7.3 serve-config)
  • mto: This revision was merged to the branch mainline in revision 364.
  • Revision ID: martin.albisetti@canonical.com-20090601002043-1e0eeztbu6q0xnkk
Merge in Peng's tab fixes

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
44
45
        config.print_help()
45
46
        sys.exit(1)
46
47
    elif config.arg_count == 1:
47
 
        [path] = args
 
48
        path = config.get_arg(0)
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"
63
64
            return Reloader.restart_with_reloader()
64
65
 
65
66
    if config.get_option('user_dirs'):
66
 
        if not config.get_option['trunk_dir']:
 
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()
77
77
    logger = getattr(app, 'log', logging.getLogger('loggerhead'))
78
78
    if config.get_option('log_folder'):
79
79
        logfile_path = os.path.join(
80
 
            config.get_option['log_folder'], 'serve-branches.log')
 
80
            config.get_option('log_folder'), 'serve-branches.log')
81
81
    else:
82
82
        logfile_path = 'serve-branches.log'
83
83
    logfile = logging.FileHandler(logfile_path, 'a')
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