~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to __init__.py

  • Committer: Martin Pool
  • Date: 2009-01-23 20:41:27 UTC
  • mto: This revision was merged to the branch mainline in revision 298.
  • Revision ID: mbp@sourcefrog.net-20090123204127-kb59jx2x1qwv2x45
serve --http handles the --port option

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
 
38
38
    takes_options = _original_command.takes_options + [
39
39
        Option('http',
40
 
            help='Run an http (Loggerhead) server to browse code.')]
 
40
            help='Run an http (Loggerhead) server to browse code, by default on port 9876.')]
41
41
 
42
42
    def run(self, *args, **kw):
43
43
        if 'http' in kw:
44
44
            # hack around loggerhead expecting to be loaded from the module
45
 
            # "loggerhead"
 
45
            # "loggerhead" - this may be wrong in some cases?
46
46
            import os.path, sys
47
47
            sys.path.append(os.path.dirname(__file__))
 
48
 
48
49
            from loggerhead.apps.filesystem import BranchesFromFileSystemRoot
49
50
            from paste.httpexceptions import HTTPExceptionHandler
50
51
            from paste.httpserver import serve
51
52
            a = HTTPExceptionHandler(BranchesFromFileSystemRoot('.'))
52
 
            serve(a, host='0.0.0.0', port='9876')
 
53
            port = kw.get('port', '9876')
 
54
            if ':' in port:
 
55
                host, port = port.split(':')
 
56
            else:
 
57
                host = '0.0.0.0'
 
58
            serve(a, host=host, port=port)
53
59
        else:
54
60
            super(cmd_serve, self).run(*args, **kw)
55
61