From 12863f1c9eacb551310fb1377368d98972db1d62 Mon Sep 17 00:00:00 2001 From: Dario Date: Thu, 23 May 2019 17:07:55 +0200 Subject: [PATCH] Fix DelugeD remove torrents when ratio is reached. Fixes #6695 (#6702) * Try to fix DelugeD remove torrents when ratio is reached. Fixes #6695 * Fix bug, standardize logging * Update CHANGELOG.md * Update CHANGELOG.md --- CHANGELOG.md | 1 + medusa/clients/torrent/deluge.py | 7 +++---- medusa/clients/torrent/deluged.py | 1 + medusa/clients/torrent/transmission.py | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e952ffcf20..a239d2c9144 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ - Fixed exception in Elite-Tracker provider when no result is found ([#6680](https://github.com/pymedusa/Medusa/pull/6680)) - Fixed exception in API v2 when an incorrect API key was provided, or none was provided ([#6703](https://github.com/pymedusa/Medusa/pull/6703)) - Removed legacy log-censoring code for Newznab providers ([#6705](https://github.com/pymedusa/Medusa/pull/6705)) +- Fixed DelugeD remove torrents when ratio is reached (Python 2.7) ([#6702](https://github.com/pymedusa/Medusa/pull/6702)) ## 0.3.1 (2019-03-20) diff --git a/medusa/clients/torrent/deluge.py b/medusa/clients/torrent/deluge.py index b0048db0216..6662e07f364 100644 --- a/medusa/clients/torrent/deluge.py +++ b/medusa/clients/torrent/deluge.py @@ -6,7 +6,6 @@ import json import logging from base64 import b64encode -from builtins import str from medusa import app from medusa.clients.torrent.generic import GenericClient @@ -22,7 +21,7 @@ from requests.compat import urljoin from requests.exceptions import RequestException -from six import viewitems +from six import text_type, viewitems log = BraceAdapter(logging.getLogger(__name__)) log.logger.addHandler(logging.NullHandler()) @@ -33,7 +32,7 @@ def read_torrent_status(torrent_data): found_torrents = False info_hash_to_remove = [] for torrent in viewitems(torrent_data): - info_hash = str(torrent[0]) + info_hash = text_type(torrent[0]) details = torrent[1] if not is_info_hash_in_history(info_hash): continue @@ -472,7 +471,7 @@ def remove_ratio_reached(self): log.info('Checking Deluge torrent status.') if self._request(method='post', data=post_data): if self.response.json()['error']: - log.info('Error while fetching torrents status') + log.warning('Error while fetching torrents status') return else: torrent_data = self.response.json()['result'] diff --git a/medusa/clients/torrent/deluged.py b/medusa/clients/torrent/deluged.py index 4ea217b9664..2dac47ec761 100644 --- a/medusa/clients/torrent/deluged.py +++ b/medusa/clients/torrent/deluged.py @@ -156,6 +156,7 @@ def remove_ratio_reached(self): log.info('Checking DelugeD torrent status.') if not self.connect(): + log.warning('Error while fetching torrents status') return torrent_data = self.drpc.get_all_torrents() diff --git a/medusa/clients/torrent/transmission.py b/medusa/clients/torrent/transmission.py index ad7a015b0aa..39b5098d9b5 100644 --- a/medusa/clients/torrent/transmission.py +++ b/medusa/clients/torrent/transmission.py @@ -279,7 +279,7 @@ def remove_ratio_reached(self): post_data = json.dumps({'arguments': return_params, 'method': 'torrent-get'}) if not self._request(method='post', data=post_data): - log.debug('Could not connect to Transmission. Check logs') + log.warning('Error while fetching torrents status') return try: