From: Holger Dell Date: Thu, 5 Jun 2014 23:04:10 +0000 (-0500) Subject: web-cmd.py: add --browser option to open the site X-Git-Tag: 0.26-rc2~9 X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=bup.git;a=commitdiff_plain;h=68f6d4c73a8479b4e9dc8b6633119f500add0101 web-cmd.py: add --browser option to open the site Signed-off-by: Holger Dell [rlb@defaultvalue.org: adjust commit message] Reviewed-by: Rob Browning --- diff --git a/Documentation/bup-web.md b/Documentation/bup-web.md index 624c9aa..08fd84d 100644 --- a/Documentation/bup-web.md +++ b/Documentation/bup-web.md @@ -26,6 +26,9 @@ can omit the bind address to bind to all available interfaces: `:8080`. --human-readable : display human readable file sizes (i.e. 3.9K, 4.7M) +--browser +: open the site in the default browser + # EXAMPLES $ bup web diff --git a/cmd/web-cmd.py b/cmd/web-cmd.py index 484041a..32e4117 100755 --- a/cmd/web-cmd.py +++ b/cmd/web-cmd.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -import sys, stat, urllib, mimetypes, posixpath, time +import sys, stat, urllib, mimetypes, posixpath, time, webbrowser from bup import options, git, vfs from bup.helpers import * try: @@ -184,6 +184,7 @@ optspec = """ bup web [[hostname]:port] -- human-readable display human readable file sizes (i.e. 3.9K, 4.7M) +browser open the site in the default browser """ o = options.Options(optspec) (opt, flags, extra) = o.parse(sys.argv[1:]) @@ -223,6 +224,9 @@ if __name__ == "__main__": sock = http_server._sockets.values()[0] print "Serving HTTP on %s:%d..." % sock.getsockname() + + if opt.browser: + webbrowser.open('http://' + address[0] + ':' + str(address[1])) + loop = tornado.ioloop.IOLoop.instance() loop.start() -