DPDK website maintenance
 help / color / mirror / Atom feed
* [dpdk-web] [PATCH 0/3] small improvements of "make local"
@ 2016-02-10 10:05 Thomas Monjalon
  2016-02-10 10:05 ` [dpdk-web] [PATCH 1/3] local: allow to force Python 2 Thomas Monjalon
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Thomas Monjalon @ 2016-02-10 10:05 UTC (permalink / raw)
  To: harry.van.haaren; +Cc: web

These are small improvements on top of the Python server sent
by Harry to test the website locally.

Thomas Monjalon (3):
  local: allow to force Python 2
  local: silent server output
  local: open in a browser

 Makefile               |  3 ++-
 scripts/serve_local.py | 13 ++++++++++++-
 2 files changed, 14 insertions(+), 2 deletions(-)

-- 
2.7.0

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [dpdk-web] [PATCH 1/3] local: allow to force Python 2
  2016-02-10 10:05 [dpdk-web] [PATCH 0/3] small improvements of "make local" Thomas Monjalon
@ 2016-02-10 10:05 ` Thomas Monjalon
  2016-02-10 10:05 ` [dpdk-web] [PATCH 2/3] local: silent server output Thomas Monjalon
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Thomas Monjalon @ 2016-02-10 10:05 UTC (permalink / raw)
  To: harry.van.haaren; +Cc: web

The default Python may be version 3 which is not compatible with
BaseHTTPServer import (integrated as http.server in 3.x).
The workaround is to specify PYTHON2=python2 on the command line.

Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
---
 Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 2a7602a..56dc512 100644
--- a/Makefile
+++ b/Makefile
@@ -1,3 +1,4 @@
+PYTHON2 = python
 
 local:
-	python scripts/serve_local.py
+	$(PYTHON2) scripts/serve_local.py
-- 
2.7.0

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [dpdk-web] [PATCH 2/3] local: silent server output
  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 ` Thomas Monjalon
  2016-02-10 10:05 ` [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
  3 siblings, 0 replies; 7+ messages in thread
From: Thomas Monjalon @ 2016-02-10 10:05 UTC (permalink / raw)
  To: harry.van.haaren; +Cc: web

The default HTTP handler prints every request on stdout.
This empty log_message will make it quiet.

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

diff --git a/scripts/serve_local.py b/scripts/serve_local.py
index 5abd9ad..bf05e86 100644
--- a/scripts/serve_local.py
+++ b/scripts/serve_local.py
@@ -40,6 +40,8 @@ class DPDK_Handler(BaseHTTPServer.BaseHTTPRequestHandler):
             f.close()
         except IOError:
             self.send_error(404, 'File Not Found: %s' % path)
+    def log_message(self, format, *args):
+        return
 
 def run(server_class=BaseHTTPServer.HTTPServer,
         handler_class=BaseHTTPServer.BaseHTTPRequestHandler):
-- 
2.7.0

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [dpdk-web] [PATCH 3/3] local: open in a browser
  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
  2016-02-10 10:17   ` Thomas Monjalon
  2016-02-15 14:33 ` [dpdk-web] [PATCH 0/3] small improvements of "make local" Van Haaren, Harry
  3 siblings, 1 reply; 7+ messages in thread
From: Thomas Monjalon @ 2016-02-10 10:05 UTC (permalink / raw)
  To: harry.van.haaren; +Cc: web

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dpdk-web] [PATCH 3/3] local: open in a browser
  2016-02-10 10:05 ` [dpdk-web] [PATCH 3/3] local: open in a browser Thomas Monjalon
@ 2016-02-10 10:17   ` Thomas Monjalon
  0 siblings, 0 replies; 7+ messages in thread
From: Thomas Monjalon @ 2016-02-10 10:17 UTC (permalink / raw)
  To: harry.van.haaren; +Cc: web

As this mailing-list needs some animation, I reply to myself:

2016-02-10 11:05, Thomas Monjalon:
> 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>
[...]
> +def open_browser():
> +    subprocess.call(["xdg-open", url])
> +
> +url = "http://localhost:%d" % port
> +print(url)
> +threading.Timer(1, open_browser).start()

I don't like opening a client in the server script.
I would prefer to put it in the Makefile:

 local:
+       (sleep 1 && xdg-open http://localhost:8000) &
        $(PYTHON2) scripts/serve_local.py

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dpdk-web] [PATCH 0/3] small improvements of "make local"
  2016-02-10 10:05 [dpdk-web] [PATCH 0/3] small improvements of "make local" Thomas Monjalon
                   ` (2 preceding siblings ...)
  2016-02-10 10:05 ` [dpdk-web] [PATCH 3/3] local: open in a browser Thomas Monjalon
@ 2016-02-15 14:33 ` Van Haaren, Harry
  2016-02-15 20:40   ` Thomas Monjalon
  3 siblings, 1 reply; 7+ messages in thread
From: Van Haaren, Harry @ 2016-02-15 14:33 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: web

> From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
> Sent: Wednesday, February 10, 2016 10:05 AM
> To: Van Haaren, Harry <harry.van.haaren@intel.com>
> Cc: web@dpdk.org
> Subject: [PATCH 0/3] small improvements of "make local"
> 
> These are small improvements on top of the Python server sent
> by Harry to test the website locally.
> 
> Thomas Monjalon (3):
>   local: allow to force Python 2
>   local: silent server output
>   local: open in a browser
> 
>  Makefile               |  3 ++-
>  scripts/serve_local.py | 13 ++++++++++++-
>  2 files changed, 14 insertions(+), 2 deletions(-)

Including the updated patch 3/3:

Series Acked-by: Harry van Haaren <harry.van.haaren@intel.com>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dpdk-web] [PATCH 0/3] small improvements of "make local"
  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
  0 siblings, 0 replies; 7+ messages in thread
From: Thomas Monjalon @ 2016-02-15 20:40 UTC (permalink / raw)
  To: web

> > These are small improvements on top of the Python server sent
> > by Harry to test the website locally.
> > 
> > Thomas Monjalon (3):
> >   local: allow to force Python 2
> >   local: silent server output
> >   local: open in a browser
> > 
> >  Makefile               |  3 ++-
> >  scripts/serve_local.py | 13 ++++++++++++-
> >  2 files changed, 14 insertions(+), 2 deletions(-)
> 
> Including the updated patch 3/3:
> 
> Series Acked-by: Harry van Haaren <harry.van.haaren@intel.com>

Applied

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2016-02-15 20:41 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [dpdk-web] [PATCH 3/3] local: open in a browser Thomas Monjalon
2016-02-10 10:17   ` 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

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).