Skip to content

Commit 562eb96

Browse files
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.
1 parent 8cc31e0 commit 562eb96

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

nikola/plugins/command/serve.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,11 @@ def _execute(self, options, args):
140140
# Some browsers fail to load 0.0.0.0 (Issue #2755)
141141
if sa[0] == '0.0.0.0':
142142
server_url = "http://127.0.0.1:{1}/".format(*sa)
143-
self.logger.info("Opening {0} in the default web browser...".format(server_url))
144-
webbrowser.open(server_url)
143+
if getattr(webbrowser.get(), "name", "") in ["www-browser", "links", "elinks", "lynx", "w3m"]:
144+
self.logger.info("Unable to open web browser, as Python could only find a terminal browser...")
145+
else:
146+
self.logger.info("Opening {0} in the default web browser...".format(server_url))
147+
webbrowser.open(server_url)
145148
if options['detach']:
146149
self.detached = True
147150
OurHTTPRequestHandler.quiet = True

0 commit comments

Comments
 (0)