48
48
config.print_help()
50
50
elif config.arg_count == 1:
51
base = config.get_arg(0)
55
if not config.get_option('allow_writes'):
56
base = 'readonly+' + base
61
def setup_logging(config):
51
path = config.get_arg(0)
57
if config.get_option('allow_writes'):
58
transport = get_transport(path)
60
transport = get_transport('readonly+' + path)
62
if config.get_option('trunk_dir') and not config.get_option('user_dirs'):
63
print "--trunk-dir is only valid with --user-dirs"
66
if config.get_option('reload'):
67
if Reloader.is_installed():
70
return Reloader.restart_with_reloader()
72
if config.get_option('user_dirs'):
73
if not config.get_option('trunk_dir'):
74
print "You didn't specify a directory for the trunk directories."
76
app = UserBranchesFromTransportRoot(transport, config)
78
app = BranchesFromTransportRoot(transport, config)
62
81
logging.basicConfig()
63
82
logging.getLogger('').setLevel(logging.DEBUG)
64
logger = logging.getLogger('loggerhead')
83
logger = getattr(app, 'log', logging.getLogger('loggerhead'))
65
84
if config.get_option('log_folder'):
66
85
logfile_path = os.path.join(
67
86
config.get_option('log_folder'), 'serve-branches.log')
73
92
logfile.setFormatter(formatter)
74
93
logfile.setLevel(logging.DEBUG)
75
94
logger.addHandler(logfile)
79
def make_app_for_config_and_path(config, base):
80
if config.get_option('trunk_dir') and not config.get_option('user_dirs'):
81
print "--trunk-dir is only valid with --user-dirs"
84
if config.get_option('reload'):
85
if Reloader.is_installed():
88
return Reloader.restart_with_reloader()
90
if config.get_option('user_dirs'):
91
if not config.get_option('trunk_dir'):
92
print "You didn't specify a directory for the trunk directories."
94
app = UserBranchesFromTransportRoot(base, config)
96
app = BranchesFromTransportRoot(base, config)
96
# setup_logging() #end
100
98
if config.get_option('profile'):
101
99
from loggerhead.middleware.profile import LSProfMiddleware
132
130
app = HTTPExceptionHandler(app)
133
131
app = ErrorHandlerApp(app)
134
app = TransLogger(app, logger=logging.getLogger('loggerhead'))
142
config, path = get_config_and_path(args)
144
app = make_app_for_config_and_path(config, path)
132
app = TransLogger(app, logger=logger)
146
134
if not config.get_option('user_port'):