Skip to content

Commit

Permalink
Pass whole config to Client object
Browse files Browse the repository at this point in the history
This will serve for future additions of new properties specific to a
`Client`.
  • Loading branch information
dolohow committed Apr 27, 2020
1 parent bd2ccbf commit 28fe00a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
5 changes: 3 additions & 2 deletions backends/transmission.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
class Client:
"""Handles connection to torrent client."""

def __init__(self, host, port):
def __init__(self, config):
"""Creates new torrent client connection.
Args:
host (str): Hostname or IP address where client is litening.
port (int): Port where client is listening.
"""
self.transmission = transmissionrpc.Client(host, port)
self.transmission = transmissionrpc.Client(config['host'],
config['port'])

def add_torrent(self, torrent, timeout=None, **kwargs):
return Torrent(self.transmission.add_torrent(torrent, timeout, **kwargs))
Expand Down
3 changes: 1 addition & 2 deletions tdpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,7 @@ def main():
backend_name = CONFIG.get('General', 'backend')

backend = importlib.import_module('backends.' + backend_name.lower())
client = backend.Client(CONFIG.get(backend_name, 'host'),
CONFIG.get(backend_name, 'port'))
client = backend.Client(CONFIG[backend_name])

init_polling(client)
torrents_tracked = set()
Expand Down

0 comments on commit 28fe00a

Please sign in to comment.