]> arthur.barton.de Git - bup.git/commitdiff
web-cmd.py: add --browser option to open the site
authorHolger Dell <holger.dell@gmail.com>
Thu, 5 Jun 2014 23:04:10 +0000 (18:04 -0500)
committerRob Browning <rlb@defaultvalue.org>
Fri, 6 Jun 2014 01:56:04 +0000 (20:56 -0500)
Signed-off-by: Holger Dell <github@holgerdell.com>
[rlb@defaultvalue.org: adjust commit message]
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Documentation/bup-web.md
cmd/web-cmd.py

index 624c9aabff74d2b874c65e6fa16324fe0a7f3aa7..08fd84dc75f190e48ea38048ad1cc984652f6448 100644 (file)
@@ -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
index 484041ac112c8993fd8e37652451ae7975203133..32e4117905ed054a2e2294e44861c977b7dd4ab4 100755 (executable)
@@ -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()
-