Private GIT

Skip to content
Snippets Groups Projects
Commit 8619de9c authored by Matt's avatar Matt
Browse files

Moved HTTP requests into 1 method to cleanup exception handling

parent 9a5e22a1
No related branches found
No related tags found
No related merge requests found
from clients.torrentclient import TorrentClient
from urllib.request import Request, urlopen, URLError
import json
import sys
import gzip
from clients.torrentclient import TorrentClient
class DelugeClient(TorrentClient):
......@@ -21,7 +22,7 @@ class DelugeClient(TorrentClient):
Add common headers needed to make the API requests
:return: request
"""
# TODO pass this to parent
self.send_log('Adding headers to request', 'debug')
headers = {
......@@ -29,13 +30,10 @@ class DelugeClient(TorrentClient):
'Accept': 'application/json'
}
for k, v in headers.items():
req.add_header(k, v)
if self.session_id:
req.add_header('Cookie', self.session_id)
headers['Cookie'] = self.session_id
return req
return TorrentClient._add_common_headers(self, req, headers=headers)
def _check_session(self):
"""
......@@ -68,7 +66,6 @@ class DelugeClient(TorrentClient):
:return:
"""
# TODO Validate method and params
data = json.dumps({
'id': self.request_id,
'method': method,
......@@ -194,7 +191,6 @@ class DelugeClient(TorrentClient):
print(e)
"""
def get_active_plugins(self):
"""
Return all active plugins
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment