~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to serve-branches

  • Committer: Michael Hudson
  • Date: 2009-04-01 15:28:21 UTC
  • Revision ID: michael.hudson@canonical.com-20090401152821-mwp2nvwl8gqbn6y1
animation fixup

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
24
23
 
25
24
from paste import httpserver
26
25
from paste.httpexceptions import HTTPExceptionHandler, HTTPInternalServerError
27
26
from paste.translogger import TransLogger
28
27
 
29
28
from loggerhead import __version__
30
 
from loggerhead.apps.transport import (
31
 
    BranchesFromTransportRoot, UserBranchesFromTransportRoot)
 
29
from loggerhead.apps.filesystem import (
 
30
    BranchesFromFileSystemRoot, UserBranchesFromFileSystemRoot)
32
31
from loggerhead.config import LoggerheadConfig
33
32
from loggerhead.util import Reloader
34
33
from loggerhead.apps.error import ErrorHandlerApp
45
44
        config.print_help()
46
45
        sys.exit(1)
47
46
    elif config.arg_count == 1:
48
 
        path = config.get_arg(0)
 
47
        [path] = args
49
48
    else:
50
49
        path = '.'
51
50
 
52
 
    load_plugins()
53
 
 
54
 
    transport = get_transport(path)
 
51
    if not os.path.isdir(path):
 
52
        print "%s is not a directory" % path
 
53
        sys.exit(1)
55
54
 
56
55
    if config.get_option('trunk_dir') and not config.get_option('user_dirs'):
57
56
        print "--trunk-dir is only valid with --user-dirs"
64
63
            return Reloader.restart_with_reloader()
65
64
 
66
65
    if config.get_option('user_dirs'):
67
 
        if not config.get_option('trunk_dir'):
 
66
        if not config.get_option['trunk_dir']:
68
67
            print "You didn't specify a directory for the trunk directories."
69
68
            sys.exit(1)
70
 
        app = UserBranchesFromTransportRoot(transport, config)
 
69
        app = UserBranchesFromFileSystemRoot(
 
70
            path, config.get_option('trunk_dir'))
71
71
    else:
72
 
        app = BranchesFromTransportRoot(transport, config)
 
72
        app = BranchesFromFileSystemRoot(path)
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
 
90
95
    # setup_logging() #end
91
96
 
92
97
    app = TransLogger(app, logger=logger)
94
99
        from loggerhead.middleware.profile import LSProfMiddleware
95
100
        app = LSProfMiddleware(app)
96
101
    if config.get_option('memory_profile'):
97
 
        from dozer import Dozer
98
 
        app = Dozer(app)
 
102
        from loggerhead.middleware.profile import MemoryProfileMiddleware
 
103
        app = MemoryProfileMiddleware(app)
99
104
 
100
105
    if not config.get_option('user_prefix'):
101
106
        prefix = '/'
135
140
    else:
136
141
        host = config.get_option('user_host')
137
142
 
 
143
    load_plugins()
 
144
 
138
145
    httpserver.serve(app, host=host, port=port)
139
146
 
140
147