From 13360171a67967b839dc6f9e98f8774815d49eac Mon Sep 17 00:00:00 2001 From: Matt <matt@mattcarey.me> Date: Sun, 22 Jan 2017 14:19:41 -0500 Subject: [PATCH] Moved HTTP requests into 1 method to cleanup exception handling --- clients/deluge.py | 2 ++ clients/torrentclient.py | 15 +++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/clients/deluge.py b/clients/deluge.py index 1a03f88..f39e319 100644 --- a/clients/deluge.py +++ b/clients/deluge.py @@ -72,6 +72,8 @@ class DelugeClient(TorrentClient): 'params': params }).encode('utf-8') + self.send_log('Calling Deluge API with method {}'.format(method), 'debug') + req = self._add_common_headers(Request(self.url, data=data)) self.request_id += 1 diff --git a/clients/torrentclient.py b/clients/torrentclient.py index e6c42f8..4a1d871 100644 --- a/clients/torrentclient.py +++ b/clients/torrentclient.py @@ -1,12 +1,6 @@ __author__ = 'barry' -import urllib.request -from urllib.request import Request, urlopen, URLError -from urllib.parse import urlsplit -from bs4 import BeautifulSoup -import json +from urllib.request import urlopen, URLError import sys -import re -import gzip # TODO Deal with slashes in client URL @@ -95,7 +89,12 @@ class TorrentClient: return res def _process_response(self, res): - # TODO May only be needed for deluge. Remove from parent if that's the case + """ + Perform response handling for the specific torrent client. Each line requires different processing/decoding of + the response + :param res: + :return: + """ raise NotImplementedError def _authenticate(self): -- GitLab