From 562eb96dff0d3961b39f51e3a90eccd9d0764501 Mon Sep 17 00:00:00 2001 From: Christopher Jefferson Date: Wed, 31 Mar 2021 18:39:38 +0100 Subject: [PATCH] Print message instead of opening command line browsers If the browser is a command line browser, opening it will pause Python which stops Nikola serving pages. --- nikola/plugins/command/serve.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/nikola/plugins/command/serve.py b/nikola/plugins/command/serve.py index 06c7422df4..37aed6e65b 100644 --- a/nikola/plugins/command/serve.py +++ b/nikola/plugins/command/serve.py @@ -140,8 +140,11 @@ def _execute(self, options, args): # Some browsers fail to load 0.0.0.0 (Issue #2755) if sa[0] == '0.0.0.0': server_url = "http://127.0.0.1:{1}/".format(*sa) - self.logger.info("Opening {0} in the default web browser...".format(server_url)) - webbrowser.open(server_url) + if getattr(webbrowser.get(), "name", "") in ["www-browser", "links", "elinks", "lynx", "w3m"]: + self.logger.info("Unable to open web browser, as Python could only find a terminal browser...") + else: + self.logger.info("Opening {0} in the default web browser...".format(server_url)) + webbrowser.open(server_url) if options['detach']: self.detached = True OurHTTPRequestHandler.quiet = True