DPDK website maintenance
 help / color / mirror / Atom feed
From: Thomas Monjalon <thomas.monjalon@6wind.com>
To: harry.van.haaren@intel.com
Cc: web@dpdk.org
Subject: [dpdk-web] [PATCH 3/3] local: open in a browser
Date: Wed, 10 Feb 2016 11:05:06 +0100	[thread overview]
Message-ID: <1455098706-23765-4-git-send-email-thomas.monjalon@6wind.com> (raw)
In-Reply-To: <1455098706-23765-1-git-send-email-thomas.monjalon@6wind.com>

When starting the local server the URL is printed and automatically open
in the default browser.
A delay is introduced to wait server initialization and avoid an error
page in the browser.

Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
---
 scripts/serve_local.py | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/scripts/serve_local.py b/scripts/serve_local.py
index bf05e86..a0b165d 100644
--- a/scripts/serve_local.py
+++ b/scripts/serve_local.py
@@ -1,6 +1,8 @@
 import BaseHTTPServer
+import threading, subprocess
 from os import curdir, sep, listdir
 
+port = 8000
 folders = [".", "./doc", "./dev"]
 
 html_files = []
@@ -45,10 +47,17 @@ class DPDK_Handler(BaseHTTPServer.BaseHTTPRequestHandler):
 
 def run(server_class=BaseHTTPServer.HTTPServer,
         handler_class=BaseHTTPServer.BaseHTTPRequestHandler):
-    server_address = ('', 8000)
+    server_address = ('', port)
     httpd = server_class(server_address, handler_class)
     httpd.serve_forever()
 
+def open_browser():
+    subprocess.call(["xdg-open", url])
+
+url = "http://localhost:%d" % port
+print(url)
+threading.Timer(1, open_browser).start()
+
 try:
     run(handler_class=DPDK_Handler)
 except BaseHTTPServer.socket.error:
-- 
2.7.0

  parent reply	other threads:[~2016-02-10 10:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-10 10:05 [dpdk-web] [PATCH 0/3] small improvements of "make local" Thomas Monjalon
2016-02-10 10:05 ` [dpdk-web] [PATCH 1/3] local: allow to force Python 2 Thomas Monjalon
2016-02-10 10:05 ` [dpdk-web] [PATCH 2/3] local: silent server output Thomas Monjalon
2016-02-10 10:05 ` Thomas Monjalon [this message]
2016-02-10 10:17   ` [dpdk-web] [PATCH 3/3] local: open in a browser Thomas Monjalon
2016-02-15 14:33 ` [dpdk-web] [PATCH 0/3] small improvements of "make local" Van Haaren, Harry
2016-02-15 20:40   ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1455098706-23765-4-git-send-email-thomas.monjalon@6wind.com \
    --to=thomas.monjalon@6wind.com \
    --cc=harry.van.haaren@intel.com \
    --cc=web@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).