Skip to content

Commit

Permalink
Merge pull request #68 from overfl0/fix_readme
Browse files Browse the repository at this point in the history
Make example code better describe its failure for newbies
  • Loading branch information
Yepoleb authored Sep 16, 2018
2 parents 526bb0e + 24c68dd commit 479768a
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,23 @@ sorted by their score.
for address in msq.find(region=[u"eu", u"as"],
gamedir=u"tf",
map=u"ctf_2fort"):
with valve.source.a2s.ServerQuerier(address) as server:
info = server.info()
players = server.players()
try:
with valve.source.a2s.ServerQuerier(address) as server:
info = server.info()
players = server.players()
except valve.source.NoResponseError:
print("Server {}:{} timed out!".format(*address))
continue
print("{player_count}/{max_players} {server_name}".format(**info))
for player in sorted(players["players"],
key=lambda p: p["score"], reverse=True):
print("{score} {name}".format(**player))
except valve.source.NoResponseError:
print "Master server request timed out!"
print("Master server request timed out!")
Versioning
Expand Down

0 comments on commit 479768a

Please sign in to comment.