From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f47.google.com (mail-wm0-f47.google.com [74.125.82.47]) by dpdk.org (Postfix) with ESMTP id 8D576559C for ; Wed, 10 Feb 2016 11:06:40 +0100 (CET) Received: by mail-wm0-f47.google.com with SMTP id g62so19851949wme.0 for ; Wed, 10 Feb 2016 02:06:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=CsThApY/xCbesejvAvRqpYCDwLulzWjco0o8qM9XXUQ=; b=hiVLK9bT7mNY/htscPGvU9Rz5GYiNG6gyZPfFWXK2W0kYGDndkVTxGvdKoOKpzy1oX acIjOIPwHO37eWDNKMfikADi0Aal7nNhAFWiKIn+tkEXMLQi6cyhvieM8wLKssb+30oQ UfavaLYYQwu59dxKKGoqCPzjvwKvbog8RRgDfYQ8gCVSK0ZoySOXXyxaWiE1wxpHxvcP 86wVcv1WcatgSgc3W2NYYXCPtnSnG/A0CUJ2ahaypds5gows6hx8dDbAdOUQIDRdB9+H mQMgy05TmPaMyusY5JoIIz+EsNOAJgDaouMM4PliU6Rx3JN23R/RqTqqXENlQmZfYGNe xJCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=CsThApY/xCbesejvAvRqpYCDwLulzWjco0o8qM9XXUQ=; b=kNBqB6GNvp87lg7Eq1o4QTDKzlZMB6yTbHo9PHFDPAALWE1yASmWlj3JW+hCcEx1oE aQQJ8dQ4IUGExmhpEIqNfuohNyH5qfLSy7RvQtcxhJ/1ltaBgbIoFHZlpWy55FI1nfTK ft4Xe6yqLS3XVfTGIPeTwfon03dU2cxARuk6G56mdyA6y6cKkvT/C/cG+Yee5WZqlhm2 xkb2MeeWyO7BBqF80+rIr5PdlEuyZ/o7nFdqmTPYEJCz/w8sjtYLEjcQkEdFxIbT+0Qm l1Rxgy0j5n4tnz2w2YXrLUYZCk67Jla8UPOebxIzFfM7IMUuvtCzg9HZTT9kHpTZUv40 xbsQ== X-Gm-Message-State: AG10YOTKFm01qzGF82Fhi6IGu2EAxNAWIpd5PLXyxAaKZ7Zn9+O6nyWBfug43NpPlYvsLjLo X-Received: by 10.194.58.169 with SMTP id s9mr34393282wjq.52.1455098800441; Wed, 10 Feb 2016 02:06:40 -0800 (PST) Received: from localhost.localdomain (136-92-190-109.dsl.ovh.fr. [109.190.92.136]) by smtp.gmail.com with ESMTPSA id hm9sm2185564wjb.34.2016.02.10.02.06.39 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 10 Feb 2016 02:06:39 -0800 (PST) From: Thomas Monjalon To: harry.van.haaren@intel.com Date: Wed, 10 Feb 2016 11:05:06 +0100 Message-Id: <1455098706-23765-4-git-send-email-thomas.monjalon@6wind.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1455098706-23765-1-git-send-email-thomas.monjalon@6wind.com> References: <1455098706-23765-1-git-send-email-thomas.monjalon@6wind.com> Cc: web@dpdk.org Subject: [dpdk-web] [PATCH 3/3] local: open in a browser X-BeenThere: web@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: website maintenance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Feb 2016 10:06:40 -0000 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 --- 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