mirror of
https://gitlab.com/LazyLibrarian/LazyLibrarian.git
synced 2026-02-06 10:47:15 +00:00
Moved more libraries to top level for unbundling, updated pyproject.toml
This commit is contained in:
parent
4fb5c1005e
commit
bcb809eec0
@ -25,7 +25,7 @@ from lazylibrarian.common import proxy_list, quotes, path_isfile, syspath, remov
|
||||
from lazylibrarian.formatter import safe_unicode, plural, clean_name, format_author_name, \
|
||||
check_int, replace_all, check_year, get_list, make_utf8bytes, unaccented, thread_name
|
||||
|
||||
from lib.thefuzz import fuzz
|
||||
from thefuzz import fuzz
|
||||
|
||||
import urllib3
|
||||
import requests
|
||||
|
||||
@ -20,7 +20,7 @@ from lazylibrarian import logger, database
|
||||
from lazylibrarian.formatter import unaccented, get_list
|
||||
from lazylibrarian.importer import add_author_name_to_db, search_for, import_book
|
||||
from lazylibrarian.librarysync import find_book_in_db
|
||||
from lib.thefuzz import fuzz
|
||||
from thefuzz import fuzz
|
||||
from lazylibrarian.common import run_script
|
||||
|
||||
# calibredb custom_columns
|
||||
|
||||
@ -25,7 +25,7 @@ from lazylibrarian.comicid import cv_identify, cx_identify
|
||||
from lazylibrarian.notifiers import notify_snatch, custom_notify_snatch
|
||||
from lazylibrarian.downloadmethods import nzb_dl_method, tor_dl_method, direct_dl_method
|
||||
|
||||
from lib.thefuzz import fuzz
|
||||
from thefuzz import fuzz
|
||||
|
||||
|
||||
# '0': '', '1': '', '2': '', '3': '', '4': '', '5': '', '6': '', '7': '', '8': '', '9': '',
|
||||
|
||||
@ -1523,12 +1523,8 @@ def log_header(online=True):
|
||||
except ImportError:
|
||||
header += "cryptography Extensions: not found\n"
|
||||
|
||||
# noinspection PyBroadException
|
||||
try:
|
||||
import lib.thefuzz as fuzz
|
||||
vers = getattr(fuzz, '__version__', None)
|
||||
except Exception:
|
||||
vers = None
|
||||
import thefuzz as fuzz
|
||||
vers = getattr(fuzz, '__version__', None)
|
||||
header += "fuzz: %s\n" % vers if vers else 'not found'
|
||||
if vers:
|
||||
# noinspection PyBroadException
|
||||
@ -1541,30 +1537,17 @@ def log_header(online=True):
|
||||
vers = "not found"
|
||||
header += "Levenshtein: %s\n" % vers
|
||||
|
||||
# noinspection PyBroadException
|
||||
import magic
|
||||
vers = 'not found'
|
||||
try:
|
||||
import magic
|
||||
bundled = False
|
||||
except Exception:
|
||||
# noinspection PyBroadException
|
||||
try:
|
||||
import lib.magic as magic
|
||||
bundled = True
|
||||
except Exception:
|
||||
magic = None
|
||||
bundled = False
|
||||
if magic is None:
|
||||
if hasattr(magic, "magic_version"):
|
||||
vers = magic.magic_version()
|
||||
else:
|
||||
# noinspection PyProtectedMember
|
||||
vers = magic.libmagic._name
|
||||
except AttributeError:
|
||||
vers = 'not found'
|
||||
else:
|
||||
try:
|
||||
if hasattr(magic, "magic_version"):
|
||||
vers = magic.magic_version()
|
||||
else:
|
||||
# noinspection PyProtectedMember
|
||||
vers = magic.libmagic._name
|
||||
except AttributeError:
|
||||
vers = 'not found'
|
||||
header += "%smagic: %s\n" % ('bundled ' if bundled else '', vers)
|
||||
header += "magic: %s\n" % vers
|
||||
|
||||
return header
|
||||
|
||||
|
||||
@ -17,17 +17,7 @@ import time
|
||||
import unicodedata
|
||||
from base64 import b16encode, b32decode, b64encode
|
||||
from hashlib import sha1
|
||||
|
||||
# noinspection PyBroadException
|
||||
try:
|
||||
# noinspection PyUnresolvedReferences
|
||||
import magic
|
||||
except Exception: # magic might fail for multiple reasons
|
||||
# noinspection PyBroadException
|
||||
try:
|
||||
import lib.magic as magic
|
||||
except Exception:
|
||||
magic = None
|
||||
import magic
|
||||
|
||||
import lazylibrarian
|
||||
from lazylibrarian import logger, database, nzbget, sabnzbd, classes, utorrent, transmission, qbittorrent, \
|
||||
@ -41,10 +31,7 @@ from lazylibrarian.postprocess import delete_task, check_contents
|
||||
from lazylibrarian.providers import block_provider
|
||||
from lazylibrarian.ircbot import irc_connect, irc_search
|
||||
|
||||
try:
|
||||
from deluge_client import DelugeRPCClient
|
||||
except ImportError:
|
||||
from lib.deluge_client import DelugeRPCClient
|
||||
from deluge_client import DelugeRPCClient
|
||||
from .magnet2torrent import magnet2torrent
|
||||
from lib.bencode import bencode, bdecode
|
||||
|
||||
|
||||
@ -24,11 +24,11 @@ from lazylibrarian.bookwork import get_work_series, get_work_page, delete_empty_
|
||||
set_series, get_status, thinglang, google_book_dict
|
||||
from lazylibrarian.images import get_book_cover
|
||||
from lazylibrarian.cache import json_request, cache_img
|
||||
from lazylibrarian.formatter import plural, today, replace_all, unaccented, unaccented_bytes, is_valid_isbn, \
|
||||
from lazylibrarian.formatter import plural, today, replace_all, unaccented, is_valid_isbn, \
|
||||
get_list, clean_name, make_unicode, make_utf8bytes, replace_quotes_with, check_year, thread_name
|
||||
from lazylibrarian.ol import OpenLibrary
|
||||
|
||||
from lib.thefuzz import fuzz
|
||||
from thefuzz import fuzz
|
||||
from urllib.parse import quote, quote_plus, urlencode
|
||||
|
||||
|
||||
|
||||
@ -26,7 +26,7 @@ from lazylibrarian.formatter import plural, today, replace_all, book_series, una
|
||||
clean_name, is_valid_isbn, format_author_name, check_int, make_unicode, check_year, check_float, \
|
||||
make_utf8bytes, thread_name
|
||||
|
||||
from lib.thefuzz import fuzz
|
||||
from thefuzz import fuzz
|
||||
from urllib.parse import quote, quote_plus, urlencode
|
||||
|
||||
|
||||
|
||||
@ -41,28 +41,8 @@ except ImportError:
|
||||
BaiduImageCrawler = None
|
||||
FlickrImageCrawler = None
|
||||
|
||||
try:
|
||||
# noinspection PyProtectedMember
|
||||
from PyPDF3 import PdfFileWriter, PdfFileReader
|
||||
except ImportError:
|
||||
try:
|
||||
# noinspection PyProtectedMember
|
||||
from lib.PyPDF3 import PdfFileWriter, PdfFileReader
|
||||
except ImportError:
|
||||
PdfFileWriter = None
|
||||
PdfFileReader = None
|
||||
|
||||
# noinspection PyBroadException
|
||||
try:
|
||||
# noinspection PyUnresolvedReferences
|
||||
import magic
|
||||
except Exception: # magic might fail for multiple reasons
|
||||
# noinspection PyBroadException
|
||||
try:
|
||||
import lib.magic as magic
|
||||
except Exception:
|
||||
magic = None
|
||||
|
||||
from PyPDF3 import PdfFileWriter, PdfFileReader
|
||||
import magic
|
||||
|
||||
GS = ''
|
||||
GS_VER = ''
|
||||
|
||||
@ -28,7 +28,7 @@ from lazylibrarian.grsync import grfollow
|
||||
from lazylibrarian.images import get_author_image
|
||||
from lazylibrarian.ol import OpenLibrary
|
||||
|
||||
from lib.thefuzz import fuzz
|
||||
from thefuzz import fuzz
|
||||
from queue import Queue
|
||||
|
||||
|
||||
|
||||
@ -35,7 +35,7 @@ from lazylibrarian.ol import OpenLibrary
|
||||
from lazylibrarian.importer import update_totals, add_author_name_to_db, search_for
|
||||
from lazylibrarian.preprocessor import preprocess_audio
|
||||
|
||||
from lib.thefuzz import fuzz
|
||||
from thefuzz import fuzz
|
||||
from lib.mobi import Mobi
|
||||
from urllib.parse import quote_plus, urlencode
|
||||
|
||||
|
||||
@ -13,10 +13,10 @@
|
||||
|
||||
import lazylibrarian
|
||||
from lazylibrarian import logger, database
|
||||
from lazylibrarian.formatter import get_list, unaccented_bytes, unaccented, plural, date_format
|
||||
from lazylibrarian.formatter import get_list, unaccented, plural, date_format
|
||||
from lazylibrarian.providers import iterate_over_rss_sites, iterate_over_torrent_sites, iterate_over_newznab_sites, \
|
||||
iterate_over_direct_sites, iterate_over_irc_sites
|
||||
from lib.thefuzz import fuzz
|
||||
from thefuzz import fuzz
|
||||
from urllib.parse import quote_plus, quote
|
||||
|
||||
|
||||
|
||||
@ -142,22 +142,9 @@ class PushBullet:
|
||||
"""
|
||||
|
||||
if not file_type:
|
||||
# noinspection PyBroadException
|
||||
try:
|
||||
# noinspection PyUnresolvedReferences
|
||||
import magic
|
||||
except Exception: # magic might fail for multiple reasons
|
||||
# noinspection PyBroadException
|
||||
try:
|
||||
import lib.magic as magic
|
||||
except Exception:
|
||||
magic = None
|
||||
|
||||
if magic:
|
||||
file_type = magic.from_buffer(fobj.read(1024))
|
||||
fobj.seek(0)
|
||||
else:
|
||||
file_type = ""
|
||||
import magic
|
||||
file_type = magic.from_buffer(fobj.read(1024))
|
||||
fobj.seek(0)
|
||||
|
||||
data = {"file_name": file_name,
|
||||
"file_type": file_type}
|
||||
|
||||
@ -25,7 +25,7 @@ import html5lib
|
||||
from bs4 import BeautifulSoup
|
||||
from urllib.parse import quote_plus
|
||||
from lazylibrarian.images import get_book_cover
|
||||
from lib.thefuzz import fuzz
|
||||
from thefuzz import fuzz
|
||||
|
||||
|
||||
class OpenLibrary:
|
||||
|
||||
@ -51,13 +51,8 @@ from lazylibrarian.mailinglist import mailing_list
|
||||
from lazylibrarian.images import create_mag_cover
|
||||
from lazylibrarian.preprocessor import preprocess_ebook, preprocess_audio, preprocess_magazine
|
||||
from lazylibrarian.notifiers import notify_download, custom_notify_download, notify_snatch, custom_notify_snatch
|
||||
|
||||
try:
|
||||
from deluge_client import DelugeRPCClient
|
||||
except ImportError:
|
||||
from lib.deluge_client import DelugeRPCClient
|
||||
|
||||
from lib.thefuzz import fuzz
|
||||
from deluge_client import DelugeRPCClient
|
||||
from thefuzz import fuzz
|
||||
|
||||
|
||||
def update_downloads(provider):
|
||||
|
||||
@ -23,16 +23,7 @@ from lazylibrarian.common import listdir, path_exists, safe_copy, safe_move, rem
|
||||
from lazylibrarian.formatter import get_list, make_unicode, check_int, human_size, now, check_float
|
||||
from lazylibrarian.images import shrink_mag
|
||||
|
||||
try:
|
||||
# noinspection PyProtectedMember
|
||||
from PyPDF3 import PdfFileWriter, PdfFileReader
|
||||
except ImportError:
|
||||
try:
|
||||
# noinspection PyProtectedMember
|
||||
from lib.PyPDF3 import PdfFileWriter, PdfFileReader
|
||||
except ImportError:
|
||||
PdfFileWriter = None
|
||||
PdfFileReader = None
|
||||
from PyPDF3 import PdfFileWriter, PdfFileReader
|
||||
|
||||
|
||||
def preprocess_ebook(bookfolder):
|
||||
|
||||
@ -24,7 +24,7 @@ from lazylibrarian.formatter import unaccented, replace_all, get_list, now, chec
|
||||
from lazylibrarian.notifiers import notify_snatch, custom_notify_snatch
|
||||
from lazylibrarian.providers import get_searchterm
|
||||
|
||||
from lib.thefuzz import fuzz
|
||||
from thefuzz import fuzz
|
||||
|
||||
|
||||
def process_result_list(resultlist, book, searchtype, source):
|
||||
|
||||
@ -19,7 +19,7 @@ from lazylibrarian.cache import fetch_url
|
||||
from lazylibrarian.formatter import plural, unaccented, make_unicode, size_in_bytes, url_fix, \
|
||||
replace_all, get_list, month2num, check_year, make_utf8bytes
|
||||
from urllib.parse import quote, urlencode, quote_plus
|
||||
from lib.thefuzz import fuzz
|
||||
from thefuzz import fuzz
|
||||
import html5lib
|
||||
from bs4 import BeautifulSoup
|
||||
import lib.feedparser as feedparser
|
||||
|
||||
@ -69,16 +69,11 @@ from lazylibrarian.rssfeed import gen_feed
|
||||
from lazylibrarian.searchbook import search_book
|
||||
from lazylibrarian.searchmag import search_magazines, download_maglist
|
||||
from lazylibrarian.searchrss import search_wishlist
|
||||
|
||||
try:
|
||||
from deluge_client import DelugeRPCClient
|
||||
except ImportError:
|
||||
from lib.deluge_client import DelugeRPCClient
|
||||
|
||||
from deluge_client import DelugeRPCClient
|
||||
from mako import exceptions
|
||||
from mako.lookup import TemplateLookup
|
||||
|
||||
from lib.thefuzz import fuzz
|
||||
from thefuzz import fuzz
|
||||
|
||||
lastauthor = ''
|
||||
lastmagazine = ''
|
||||
|
||||
@ -1,289 +0,0 @@
|
||||
import socket
|
||||
import ssl
|
||||
import struct
|
||||
import warnings
|
||||
import zlib
|
||||
import lazylibrarian
|
||||
from lazylibrarian import logger
|
||||
|
||||
from .rencode import dumps, loads
|
||||
|
||||
RPC_RESPONSE = 1
|
||||
RPC_ERROR = 2
|
||||
RPC_EVENT = 3
|
||||
|
||||
MESSAGE_HEADER_SIZE = 5
|
||||
READ_SIZE = 10
|
||||
|
||||
# logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class DelugeClientException(Exception):
|
||||
"""Base exception for all deluge client exceptions"""
|
||||
|
||||
|
||||
class ConnectionLostException(DelugeClientException):
|
||||
pass
|
||||
|
||||
|
||||
class CallTimeoutException(DelugeClientException):
|
||||
pass
|
||||
|
||||
|
||||
class InvalidHeaderException(DelugeClientException):
|
||||
pass
|
||||
|
||||
|
||||
class FailedToReconnectException(DelugeClientException):
|
||||
pass
|
||||
|
||||
|
||||
class RemoteException(DelugeClientException):
|
||||
pass
|
||||
|
||||
|
||||
class DelugeRPCClient(object):
|
||||
timeout = 20
|
||||
|
||||
def __init__(self, host, port, username, password, decode_utf8=False, automatic_reconnect=True):
|
||||
self.host = host
|
||||
self.port = port
|
||||
self.username = username
|
||||
self.password = password
|
||||
self.deluge_version = None
|
||||
# This is only applicable if deluge_version is 2
|
||||
self.deluge_protocol_version = None
|
||||
self.daemon_version = None
|
||||
|
||||
self.decode_utf8 = decode_utf8
|
||||
if not self.decode_utf8:
|
||||
warnings.warn('Using `decode_utf8=False` is deprecated, please set it to True.'
|
||||
'The argument will be removed in a future release where it will be always True',
|
||||
DeprecationWarning)
|
||||
|
||||
self.automatic_reconnect = automatic_reconnect
|
||||
|
||||
self.request_id = 1
|
||||
self.connected = False
|
||||
self._socket = None
|
||||
self._create_socket()
|
||||
|
||||
def _create_socket(self, ssl_version=None):
|
||||
if ssl_version is not None:
|
||||
self._socket = ssl.wrap_socket(socket.socket(socket.AF_INET, socket.SOCK_STREAM), ssl_version=ssl_version)
|
||||
else:
|
||||
self._socket = ssl.wrap_socket(socket.socket(socket.AF_INET, socket.SOCK_STREAM))
|
||||
self._socket.settimeout(self.timeout)
|
||||
|
||||
def connect(self):
|
||||
"""
|
||||
Connects to the Deluge instance
|
||||
"""
|
||||
self._connect()
|
||||
if lazylibrarian.LOGLEVEL & lazylibrarian.log_dlcomms:
|
||||
logger.debug('Connected to Deluge, detecting daemon version')
|
||||
self._detect_deluge_version()
|
||||
if lazylibrarian.LOGLEVEL & lazylibrarian.log_dlcomms:
|
||||
logger.debug('Daemon version {} detected, logging in'.format(self.deluge_version))
|
||||
if self.deluge_version == 2:
|
||||
result = self.call('daemon.login', self.username, self.password, client_version='deluge-client')
|
||||
else:
|
||||
result = self.call('daemon.login', self.username, self.password)
|
||||
logger.debug('Logged into Deluge with value %r' % result)
|
||||
self.connected = True
|
||||
|
||||
def _connect(self):
|
||||
logger.info('Connecting to %s:%s' % (self.host, self.port))
|
||||
try:
|
||||
self._socket.connect((self.host, self.port))
|
||||
except ssl.SSLError as e:
|
||||
# Note: have not verified that we actually get errno 258 for this error
|
||||
if (hasattr(ssl, 'PROTOCOL_SSLv3') and
|
||||
(getattr(e, 'reason', None) == 'UNSUPPORTED_PROTOCOL' or e.errno == 258)):
|
||||
logger.warn('Was unable to ssl handshake, trying to force SSLv3 (insecure)')
|
||||
self._create_socket(ssl_version=ssl.PROTOCOL_SSLv3)
|
||||
self._socket.connect((self.host, self.port))
|
||||
else:
|
||||
raise
|
||||
|
||||
def disconnect(self):
|
||||
"""
|
||||
Disconnect from deluge
|
||||
"""
|
||||
if self.connected:
|
||||
self._socket.close()
|
||||
self._socket = None
|
||||
self.connected = False
|
||||
|
||||
def _detect_deluge_version(self):
|
||||
if self.deluge_version is not None:
|
||||
return
|
||||
|
||||
self._send_call(1, None, 'daemon.info')
|
||||
self._send_call(2, None, 'daemon.info')
|
||||
self._send_call(2, 1, 'daemon.info')
|
||||
result = self._socket.recv(1)
|
||||
if result[:1] == b'D':
|
||||
# This is a protocol deluge 2.0 was using before release
|
||||
self.deluge_version = 2
|
||||
self.deluge_protocol_version = None
|
||||
# If we need the specific version of deluge 2, this is it.
|
||||
self.daemon_version = self._receive_response(2, None, partial_data=result)
|
||||
elif ord(result[:1]) == 1:
|
||||
self.deluge_version = 2
|
||||
self.deluge_protocol_version = 1
|
||||
# If we need the specific version of deluge 2, this is it.
|
||||
self.daemon_version = self._receive_response(2, 1, partial_data=result)
|
||||
else:
|
||||
self.deluge_version = 1
|
||||
# Deluge 1 doesn't recover well from the bad request. Re-connect the socket.
|
||||
self._socket.close()
|
||||
self._create_socket()
|
||||
self._connect()
|
||||
|
||||
def _send_call(self, deluge_version, protocol_version, method, *args, **kwargs):
|
||||
self.request_id += 1
|
||||
if method == 'daemon.login':
|
||||
debug_args = list(args)
|
||||
if len(debug_args) >= 2:
|
||||
debug_args[1] = '<password hidden>'
|
||||
if lazylibrarian.LOGLEVEL & lazylibrarian.log_dlcomms:
|
||||
logger.debug('Calling reqid %s method %r with args:%r kwargs:%r' %
|
||||
(self.request_id, method, debug_args, kwargs))
|
||||
else:
|
||||
if lazylibrarian.LOGLEVEL & lazylibrarian.log_dlcomms:
|
||||
logger.debug('Calling reqid %s method %r with args:%r kwargs:%r' %
|
||||
(self.request_id, method, args, kwargs))
|
||||
|
||||
req = ((self.request_id, method, args, kwargs), )
|
||||
req = zlib.compress(dumps(req))
|
||||
|
||||
if deluge_version == 2:
|
||||
if protocol_version is None:
|
||||
# This was a protocol for deluge 2 before they introduced protocol version numbers
|
||||
self._socket.send(b'D' + struct.pack("!i", len(req)))
|
||||
elif protocol_version == 1:
|
||||
self._socket.send(struct.pack('!BI', protocol_version, len(req)))
|
||||
else:
|
||||
raise Exception('Deluge protocol version {} is not (yet) supported.'.format(protocol_version))
|
||||
self._socket.send(req)
|
||||
|
||||
def _receive_response(self, deluge_version, protocol_version, partial_data=b''):
|
||||
expected_bytes = None
|
||||
data = partial_data
|
||||
while True:
|
||||
try:
|
||||
d = self._socket.recv(READ_SIZE)
|
||||
except ssl.SSLError:
|
||||
raise CallTimeoutException()
|
||||
|
||||
data += d
|
||||
if deluge_version == 2:
|
||||
if expected_bytes is None:
|
||||
if len(data) < 5:
|
||||
continue
|
||||
|
||||
header = data[:MESSAGE_HEADER_SIZE]
|
||||
data = data[MESSAGE_HEADER_SIZE:]
|
||||
|
||||
if protocol_version is None:
|
||||
if header[0] != b'D'[0]:
|
||||
raise InvalidHeaderException('Expected D as first byte in reply')
|
||||
elif ord(header[:1]) != protocol_version:
|
||||
raise InvalidHeaderException(
|
||||
'Expected protocol version ({}) as first byte in reply'.format(protocol_version)
|
||||
)
|
||||
|
||||
if protocol_version is None:
|
||||
expected_bytes = struct.unpack('!i', header[1:])[0]
|
||||
else:
|
||||
expected_bytes = struct.unpack('!I', header[1:])[0]
|
||||
|
||||
if len(data) >= expected_bytes:
|
||||
data = zlib.decompress(data)
|
||||
break
|
||||
else:
|
||||
try:
|
||||
data = zlib.decompress(data)
|
||||
except zlib.error:
|
||||
if not d:
|
||||
raise ConnectionLostException()
|
||||
continue
|
||||
break
|
||||
|
||||
data = list(loads(data, decode_utf8=self.decode_utf8))
|
||||
msg_type = data.pop(0)
|
||||
_ = data.pop(0) # request_id
|
||||
|
||||
if msg_type == RPC_ERROR:
|
||||
if self.deluge_version == 2:
|
||||
exception_type, exception_msg, _, traceback = data
|
||||
# On deluge 2, exception arguments are sent as tuple
|
||||
if self.decode_utf8:
|
||||
exception_msg = ', '.join(exception_msg)
|
||||
else:
|
||||
exception_msg = b', '.join(exception_msg)
|
||||
else:
|
||||
exception_type, exception_msg, traceback = data[0]
|
||||
if self.decode_utf8:
|
||||
exception = type(str(exception_type), (RemoteException, ), {})
|
||||
exception_msg = '%s\n%s' % (exception_msg,
|
||||
traceback)
|
||||
else:
|
||||
exception = type(str(exception_type.decode('utf-8', 'ignore')), (RemoteException, ), {})
|
||||
exception_msg = '%s\n%s' % (exception_msg.decode('utf-8', 'ignore'),
|
||||
traceback.decode('utf-8', 'ignore'))
|
||||
if lazylibrarian.LOGLEVEL & lazylibrarian.log_dlcomms:
|
||||
logger.debug("RPC Error: %s" % exception_msg)
|
||||
raise exception(exception_msg)
|
||||
elif msg_type == RPC_RESPONSE:
|
||||
retval = data[0]
|
||||
if lazylibrarian.LOGLEVEL & lazylibrarian.log_dlcomms:
|
||||
logger.debug(str(retval))
|
||||
return retval
|
||||
|
||||
def reconnect(self):
|
||||
"""
|
||||
Reconnect
|
||||
"""
|
||||
self.disconnect()
|
||||
self._create_socket()
|
||||
self.connect()
|
||||
|
||||
def call(self, method, *args, **kwargs):
|
||||
"""
|
||||
Calls an RPC function
|
||||
"""
|
||||
tried_reconnect = False
|
||||
for _ in range(2):
|
||||
try:
|
||||
self._send_call(self.deluge_version, self.deluge_protocol_version, method, *args, **kwargs)
|
||||
return self._receive_response(self.deluge_version, self.deluge_protocol_version)
|
||||
except (socket.error, ConnectionLostException, CallTimeoutException):
|
||||
if self.automatic_reconnect:
|
||||
if tried_reconnect:
|
||||
raise FailedToReconnectException()
|
||||
else:
|
||||
try:
|
||||
self.reconnect()
|
||||
except (socket.error, ConnectionLostException, CallTimeoutException):
|
||||
raise FailedToReconnectException()
|
||||
|
||||
tried_reconnect = True
|
||||
else:
|
||||
raise
|
||||
|
||||
def __getattr__(self, item):
|
||||
return RPCCaller(self.call, item)
|
||||
|
||||
|
||||
class RPCCaller(object):
|
||||
def __init__(self, caller, method=''):
|
||||
self.caller = caller
|
||||
self.method = method
|
||||
|
||||
def __getattr__(self, item):
|
||||
return RPCCaller(self.caller, self.method+'.'+item)
|
||||
|
||||
def __call__(self, *args, **kwargs):
|
||||
return self.caller(self.method, *args, **kwargs)
|
||||
@ -1,5 +1,38 @@
|
||||
# Config file for pytest
|
||||
[build-system]
|
||||
requires = ["setuptools"]
|
||||
build-backend = "setuptools.build_meta"
|
||||
|
||||
[tool.setuptools]
|
||||
packages = ["lazylibrarian"]
|
||||
|
||||
[project]
|
||||
name = "LazyLibrarian"
|
||||
version = "2022.12.05"
|
||||
description = "LazyLibrarian is a SickBeard, CouchPotato, Headphones-like application for ebooks, audiobooks and magazines"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.7"
|
||||
|
||||
dependencies = [
|
||||
'bs4',
|
||||
'html5lib',
|
||||
'webencodings',
|
||||
'requests',
|
||||
'urllib3',
|
||||
'cherrypy',
|
||||
'cherrypy_cors',
|
||||
'httpagentparser',
|
||||
'mako',
|
||||
'httplib2',
|
||||
'Pillow',
|
||||
'apprise',
|
||||
'PyPDF3',
|
||||
'python_magic',
|
||||
'thefuzz[speedup]',
|
||||
'deluge_client'
|
||||
]
|
||||
|
||||
|
||||
# Config file for pytest
|
||||
[tool.pytest.ini_options]
|
||||
pythonpath = "."
|
||||
filterwarnings = [
|
||||
|
||||
@ -2,7 +2,7 @@ from __future__ import unicode_literals
|
||||
import sys
|
||||
import functools
|
||||
|
||||
from lib.thefuzz.string_processing import StringProcessor
|
||||
from thefuzz.string_processing import StringProcessor
|
||||
|
||||
|
||||
PY3 = sys.version_info[0] == 3
|
||||
Loading…
Reference in New Issue
Block a user