Skip to content

Commit

Permalink
Bump transmission-rpc to > 3.0
Browse files Browse the repository at this point in the history
transmission-rpc broke compatibility in Client() class's signature. We
adapt our own code to honor that one and switch to testing against
versions only past 3.0

Signed-off-by: Alexandros Kosiaris <akosiaris@gmail.com>
  • Loading branch information
akosiaris committed Jun 17, 2024
1 parent c003179 commit 53f0eea
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pylint 'transmission-rpc<3.0'
pip install pylint 'transmission-rpc>=3.0'
- name: Analysing the code with pylint
run: |
pylint --ignore=conf.py $(git ls-files '*.py')
11 changes: 9 additions & 2 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,15 @@ jobs:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
transmission-rpc-version:
- "1.0.7"
- "2.0.4"
- "3.0.1"
- "3.1.0"
- "3.2.9"
- "3.3.2"
- "3.4.2"
- "4.0.0"
- "4.1.5"
- "4.2.2"
- "4.3.0"

steps:
- uses: actions/checkout@v3
Expand Down
10 changes: 7 additions & 3 deletions collectd_transmission/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,16 @@ def initialize():
'''
username = data['username']
password = data['password']
address = data.get('address', 'http://localhost:9091/transmission/rpc')
host = data.get('host', 'localhost')
port = data.get('port', 9091)
path = data.get('path', '/transmission/rpc')
timeout = int(data.get('timeout', '5'))
try:
client = transmission_rpc.Client(
address=address,
user=username,
host=host,
path=path,
port=port,
username=username,
password=password,
timeout=timeout)
except transmission_rpc.error.TransmissionError:
Expand Down
6 changes: 3 additions & 3 deletions doc/compatibility.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Compatibility
=============

As long as you can install collectd 5.x with the python plugin and
transmission-rpc less than 3.0 it should work out of the box.
transmission-rpc higher than 3.0 it should work out of the box.

transmission-rpc
================
Expand All @@ -14,8 +14,8 @@ apparently and is still seeing updates. It has switched to SemVer,
allowing us to more easily test against the major releases and decide on
how to proceed. There are a number of identified notes here:

* Versions 3.0+ broke the Client() class signature and for now we can't
use them
* Versions 3.0+ broke the Client() class signature. We 've adapted, but this
means we can't use versions below 3.0
* Versions 0.0.x and 0.1.0 used the python 2/3 compatibility layer named
six. Given that we don't even want to support python 2.x anymore, we
'll be skipping those releases to avoid installing a redundant
Expand Down
11 changes: 8 additions & 3 deletions doc/configure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,17 @@ Insert the following in your collectd.conf::
<Module collectd_transmission>
username "myuser" # Required
password "mypass" # Required
address "http://localhost:9091/transmission/rpc" # Optional, defaults to "http://localhost:9091/transmission/rpc"
timeout "5" # Optional, defaults to 5
host "localhost" # Optional
port "9091" # Optional
path "/transmission/rpc" # Optional
timeout "5" # Optional
</Module>
</Plugin>

modified accordingly to your needs. Restart collectd and you are done.
modified accordingly to your needs. Everything marked as optional, can be
skipped. The default value is given for your convenience

Restart collectd and you are done.

.. code-block:: bash
Expand Down
2 changes: 1 addition & 1 deletion doc/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ via pip

.. code-block:: bash
pip install 'transmission-rpc<3.0'
pip install 'transmission-rpc>3.0'
Install collectd.

Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ classifiers =
[options]
packages = collectd_transmission
install_requires =
transmission-rpc < 3.0
transmission-rpc >= 3.0
importlib-metadata; python_version < "3.10"
include_package_data = True
python_requires = >=3.9
16 changes: 11 additions & 5 deletions tests/test_collectd_transmission.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ def test_config(self):

collectd_transmission.configuration(self.config)

@mock.patch('collectd_transmission.transmission_rpc.Client', spec=True)
@mock.patch(
'collectd_transmission.transmission_rpc.Client',
spec=True)
def test_initialize(self, mock_client):
'''
Test the initialization
Expand All @@ -53,8 +55,10 @@ def test_initialize(self, mock_client):
collectd_transmission.configuration(self.config)
collectd_transmission.initialize()
mock_client.assert_called_with(
address='http://localhost:9091/transmission/rpc',
user='myusername',
host='localhost',
path='/transmission/rpc',
port=9091,
username='myusername',
password='mypassword',
timeout=5)

Expand All @@ -70,8 +74,10 @@ def test_initialize_fail(self, mock_client):
collectd_transmission.configuration(self.config)
collectd_transmission.initialize()
mock_client.assert_called_with(
address='http://localhost:9091/transmission/rpc',
user='myusername',
host='localhost',
path='/transmission/rpc',
port=9091,
username='myusername',
password='mypassword',
timeout=5)

Expand Down

0 comments on commit 53f0eea

Please sign in to comment.