From 0d3691860335878f9db6fdc720198863f3a964bc Mon Sep 17 00:00:00 2001 From: Gabriel Huber Date: Mon, 25 Sep 2017 23:22:16 +0200 Subject: [PATCH 01/14] Fix super call of request method --- valve/source/a2s.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/valve/source/a2s.py b/valve/source/a2s.py index 28103eb..3322fa5 100644 --- a/valve/source/a2s.py +++ b/valve/source/a2s.py @@ -25,7 +25,8 @@ class ServerQuerier(valve.source.BaseQuerier): """ def request(self, request): - self.request(messages.Header(split=messages.NO_SPLIT), request) + super(ServerQuerier, self).request( + messages.Header(split=messages.NO_SPLIT), request) def get_response(self): From aaf9c27a96ca7edb44c1a308282917f30aea1c24 Mon Sep 17 00:00:00 2001 From: Oliver Ainsworth Date: Tue, 26 Sep 2017 14:09:09 +0100 Subject: [PATCH 02/14] Update some package metadata for 0.2.1 --- setup.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 9c96914..2582d8e 100644 --- a/setup.py +++ b/setup.py @@ -30,12 +30,13 @@ def install_requires(): setuptools.setup( name="python-valve", version="0.2.0", - description=("Python implemntation RCON, A2S, VDF, the Steam Web " - "API and various other Valve products and services."), + description=("Python implementation for Source servers, RCON, A2S, " + "VDF, the Steam Web API and various other Valve products " + "and services."), long_description=readme(), author="Oliver Ainsworth", author_email="ottajay@googlemail.com", - url="https://github.com/Holiverh/python-valve", + url="https://github.com/serverstf/python-valve", packages=setuptools.find_packages(exclude=["tests"]), install_requires=install_requires(), extras_require={ From 6f2ca953d75d1d2204a00d9ff5efc43180c89d90 Mon Sep 17 00:00:00 2001 From: Oliver Ainsworth Date: Tue, 26 Sep 2017 14:09:42 +0100 Subject: [PATCH 03/14] Set version to 0.2.1 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 2582d8e..c9880d7 100644 --- a/setup.py +++ b/setup.py @@ -29,7 +29,7 @@ def install_requires(): setuptools.setup( name="python-valve", - version="0.2.0", + version="0.2.1", description=("Python implementation for Source servers, RCON, A2S, " "VDF, the Steam Web API and various other Valve products " "and services."), From b5a543f13417bce4015b0f6f6967b6d47cfd5fc2 Mon Sep 17 00:00:00 2001 From: Oliver Ainsworth Date: Thu, 28 Sep 2017 21:54:49 +0100 Subject: [PATCH 04/14] Fix broken import in RCON README example --- README.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.rst b/README.rst index 21fb91f..10eca17 100644 --- a/README.rst +++ b/README.rst @@ -28,12 +28,12 @@ a simple ``echo`` command to it. .. code:: python - from valve.source.rcon import RCON + import valve.rcon - SERVER_ADDRESS = ("...", 27015) - PASSWORD = "top_secret" + server_address = ("...", 27015) + password = "top_secret" - with RCON(SERVER_ADDRESS, PASSWORD) as rcon: + with valve.rcon.RCON(server_address, password) as rcon: print(rcon("echo Hello, world!")) From 076883911f274fdbc8943e97731fdd5d62d0d03f Mon Sep 17 00:00:00 2001 From: Rithwik Jayasimha Date: Thu, 12 Oct 2017 11:52:14 +0530 Subject: [PATCH 05/14] Create CONTRIBUTING.md To do: Fill in with guidelines. --- CONTRIBUTING.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1 @@ + From 13d6f81da37cacaabe8bdf9ffe387b70ab754bda Mon Sep 17 00:00:00 2001 From: Rithwik Jayasimha Date: Fri, 13 Oct 2017 21:11:35 +0530 Subject: [PATCH 06/14] Delete offending file --- CONTRIBUTING.md | 1 - 1 file changed, 1 deletion(-) delete mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index 8b13789..0000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1 +0,0 @@ - From 7b031b62d9ce6d9a075e5563cae8a6f460137aeb Mon Sep 17 00:00:00 2001 From: nitroflow Date: Sun, 22 Oct 2017 17:17:13 +0100 Subject: [PATCH 07/14] Fixed some typos 68c68 < time_sent = monontic.monotonic() --- > time_sent = monotonic.monotonic() 72c72 < return (time_received - t_sent) * 1000.0 --- > return (time_received - time_sent) * 1000.0 --- valve/source/a2s.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/valve/source/a2s.py b/valve/source/a2s.py index 3322fa5..c916b60 100644 --- a/valve/source/a2s.py +++ b/valve/source/a2s.py @@ -65,11 +65,11 @@ def ping(self): be negligble. """ - time_sent = monontic.monotonic() + time_sent = monotonic.monotonic() self.request(messages.InfoRequest()) messages.InfoResponse.decode(self.get_response()) time_received = monotonic.monotonic() - return (time_received - t_sent) * 1000.0 + return (time_received - time_sent) * 1000.0 def info(self): """Retreive information about the server state From c2981c76bde9b151edfa457912304cf2a8927235 Mon Sep 17 00:00:00 2001 From: CzBiX Date: Tue, 7 Nov 2017 17:13:47 +0800 Subject: [PATCH 08/14] Exit the rcon shell by Ctrl-D shortcut. --- valve/rcon.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/valve/rcon.py b/valve/rcon.py index 1ffe97e..ccd808f 100644 --- a/valve/rcon.py +++ b/valve/rcon.py @@ -733,6 +733,9 @@ def _disconnect(self): self._convars = () self.prompt = self._INITIAL_PROMPT + def _exit(self): + self._disconnect() + def default(self, command): """Issue a command as an RCON command. @@ -776,6 +779,11 @@ def do_exit(self, _): print("Use !exit to exit this shell or " "!shutdown to shutdown the server.") + def do_EOF(self, _): + """Exit by the Ctrl-D shortcut.""" + self._exit() + return True + def do_help(self, command): """Print out ConVar-specific or generic help. @@ -818,6 +826,7 @@ def do_shell(self, command_string): def do_shell_exit(self, argv): """Exit the shell.""" + self._exit() return True def do_shell_connect(self, argv): From d0e19ebcf02ed558ae432641ed39938a512ce61c Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Fri, 15 Dec 2017 10:30:49 +0100 Subject: [PATCH 09/14] Fix some typos in README --- README.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 10eca17..ac4ef76 100644 --- a/README.rst +++ b/README.rst @@ -23,7 +23,7 @@ To get started, install Python-valve with pip: RCON Example ------------ -In this example we connect to a Source servers remote console and issue +In this example we connect to a Source server's remote console and issue a simple ``echo`` command to it. .. code:: python @@ -113,7 +113,7 @@ dependencies, build the docs and then open them in a browser. Python 2 -------- -Python-valve supports Python 2.7! However, it's important to bare in +Python-valve supports Python 2.7! However, it's important to bear in mind that Python 2.7 will not be maintained past 2020. Python-valve *may* drop support for Python 2.7 in a future major release before 2020 in order to make use of new, non-backwards compatible Python 3 features. From 24c68dd9cff125ec5cbaabb5646e12dff96cb816 Mon Sep 17 00:00:00 2001 From: Lukasz Taczuk Date: Sat, 15 Sep 2018 15:08:56 +0200 Subject: [PATCH 10/14] Use a separate try/except per server for timeout detection Use python3 print everywhere. --- README.rst | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/README.rst b/README.rst index ac4ef76..978cf8b 100644 --- a/README.rst +++ b/README.rst @@ -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 From f7da20db431a2504dc31e719b379e1228fea8e8e Mon Sep 17 00:00:00 2001 From: Nikita Pushchin Date: Mon, 11 Mar 2019 16:25:33 +0300 Subject: [PATCH 11/14] valve.source.a2s - BaseQuerier bug fixed --- valve/source/a2s.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/valve/source/a2s.py b/valve/source/a2s.py index c916b60..c19654c 100644 --- a/valve/source/a2s.py +++ b/valve/source/a2s.py @@ -49,7 +49,7 @@ def get_response(self): raise NotImplementedError("Fragments are compressed") fragments[fragment["fragment_id"]] = fragment while len(fragments) < fragment["fragment_count"]: - data = BaseQuerier.get_response(self) + data = valve.source.BaseQuerier.get_response(self) fragment = messages.Fragment.decode( messages.Header.decode(data).payload) fragments[fragment["fragment_id"]] = fragment From e0f7e1bca4473129657fbbbad93fa4d9df436d40 Mon Sep 17 00:00:00 2001 From: Richard Schwab Date: Wed, 27 Mar 2019 09:07:47 +0100 Subject: [PATCH 12/14] Bump pytest version to >=3.6.0 Stop using deprecated pytest_namespace(): https://docs.pytest.org/en/latest/deprecations.html#pytest-namespace Remove pytest-capturelog as it was merged to pytest core --- setup.py | 3 +-- tests/conftest.py | 10 ++++------ tox.ini | 3 +-- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/setup.py b/setup.py index c9880d7..9f9a78f 100644 --- a/setup.py +++ b/setup.py @@ -45,8 +45,7 @@ def install_requires(): ], "test": [ "mock==1.0.1", - "pytest>=2.8.0", - "pytest-capturelog", + "pytest>=3.6.0", "pytest-cov", "pytest-timeout", ], diff --git a/tests/conftest.py b/tests/conftest.py index 06e0bff..ac2615e 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -95,12 +95,10 @@ def pytest_generate_tests(metafunc): metafunc.parametrize("address", server_addresses) -def pytest_namespace(): - return { - "Mock": mock.Mock, - "MagicMock": mock.MagicMock, - "srcds_functional": srcds_functional, - } +def pytest_configure(): + pytest.Mock = mock.Mock + pytest.MagicMock = mock.MagicMock + pytest.srcds_functional = srcds_functional @pytest.yield_fixture diff --git a/tox.ini b/tox.ini index 48513d2..1fc8b8c 100644 --- a/tox.ini +++ b/tox.ini @@ -5,7 +5,6 @@ envlist = py27, py34, pypy deps = docopt>=0.6.2 mock==1.0.1 - pytest>=2.8.0 - pytest-capturelog + pytest>=3.6.0 pytest-timeout commands = py.test tests/ From 8a1cf6769206290b5b13dd45cfdba6a0185759b2 Mon Sep 17 00:00:00 2001 From: Gabriel Huber Date: Fri, 12 Apr 2019 00:40:02 +0200 Subject: [PATCH 13/14] Increase response receive buffer size --- valve/source/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/valve/source/__init__.py b/valve/source/__init__.py index 1b38712..b59a83c 100644 --- a/valve/source/__init__.py +++ b/valve/source/__init__.py @@ -120,7 +120,7 @@ def get_response(self): if not ready[0]: raise NoResponseError("Timed out waiting for response") try: - data = ready[0][0].recv(1400) + data = ready[0][0].recv(65536) except socket.error as exc: six.raise_from(NoResponseError(exc)) return data From 963086a385b771a9d58a757814a5cea8111c1c8b Mon Sep 17 00:00:00 2001 From: Gabriel Huber Date: Fri, 17 Jan 2020 06:27:53 +0100 Subject: [PATCH 14/14] Add note about unmaintained status --- README.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.rst b/README.rst index 978cf8b..f30dcfe 100644 --- a/README.rst +++ b/README.rst @@ -19,6 +19,13 @@ interface to various Valve products and services, including: To get started, install Python-valve with pip: ``pip install python-valve``. +UNMAINTAINED +------------ + +This project is no longer actively maintained. The server query part +has been rewritten and is available as +`python-a2s `__ to not break +compatibility with projects using the old API. RCON Example ------------