Skip to content

Commit

Permalink
Improve CLI error message during query timeouts
Browse files Browse the repository at this point in the history
Fixes #72
  • Loading branch information
kevinkjt2000 committed Apr 11, 2021
1 parent 3d4c2e7 commit 3096a65
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion mcstatus/scripts/mcstatus.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import socket
import click
from json import dumps as json_dumps

Expand Down Expand Up @@ -110,7 +111,13 @@ def query():
Prints detailed server information. Must be enabled in
servers' server.properties file.
"""
response = server.query()
try:
response = server.query()
except socket.timeout:
print("""The server did not respond to the query protocol.
Please ensure that the server has enable-query turned on, and that the necessary port (same as server-port unless query-port is set) is open in any firewall(s).
See https://wiki.vg/Query for further information.""")
raise click.Abort()
click.echo("host: {}:{}".format(response.raw['hostip'], response.raw['hostport']))
click.echo("software: v{} {}".format(response.software.version, response.software.brand))
click.echo("plugins: {}".format(response.software.plugins))
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

setup(
name="mcstatus",
version="5.1.3",
version="5.1.4",
author="Nathan Adams",
author_email="[email protected]",
url="https://pypi.python.org/pypi/mcstatus",
Expand Down

0 comments on commit 3096a65

Please sign in to comment.