diff --git a/SABnzbd.py b/SABnzbd.py index 62933f7..098afd2 100755 --- a/SABnzbd.py +++ b/SABnzbd.py @@ -405,11 +405,19 @@ def GetProfileInfo(vista_plus): def print_modules(): """ Log all detected optional or external modules """ - if sabnzbd.decoder.HAVE_SABYENC: - logging.info("SABYenc module (v%s)... found!", sabnzbd.constants.SABYENC_VERSION) + if sabnzbd.decoder.SABYENC_ENABLED: + # Yes, we have SABYenc, and it's the correct version, so it's enabled + logging.info("SABYenc module (v%s)... found!", sabnzbd.constants.SABYENC_VERSION_REQUIRED) else: - logging.warning("SABYenc module... NOT found! Expecting v%s - https://sabnzbd.org/sabyenc", sabnzbd.constants.SABYENC_VERSION) - # Only now we care about old-yEnc + # Something wrong with SABYenc, so let's determine and print what: + if sabnzbd.decoder.SABYENC_VERSION: + # We have a VERSION, thus a SABYenc module, but it's not the correct version + logging.warning(T("SABYenc disabled: no correct version found! (Found v%s, expecting v%s)" % (sabnzbd.decoder.SABYENC_VERSION, sabnzbd.constants.SABYENC_VERSION_REQUIRED))) + else: + # No SABYenc module at all + logging.warning(T("SABYenc module... NOT found! Expecting v%s - https://sabnzbd.org/sabyenc", sabnzbd.constants.SABYENC_VERSION_REQUIRED)) + + # No correct SABYenc version or no SABYenc at all, so now we care about old-yEnc if sabnzbd.decoder.HAVE_YENC: logging.info("_yenc module... found!") else: diff --git a/sabnzbd/constants.py b/sabnzbd/constants.py index 975ddf4..a6b19a0 100644 --- a/sabnzbd/constants.py +++ b/sabnzbd/constants.py @@ -52,7 +52,7 @@ RENAMES_FILE = '__renames__' ATTRIB_FILE = 'SABnzbd_attrib' REPAIR_REQUEST = 'repair-all.sab' -SABYENC_VERSION = '3.0.1' +SABYENC_VERSION_REQUIRED = '3.0.1' DB_HISTORY_VERSION = 1 DB_QUEUE_VERSION = 1 diff --git a/sabnzbd/decoder.py b/sabnzbd/decoder.py index 55f445e..237ac69 100644 --- a/sabnzbd/decoder.py +++ b/sabnzbd/decoder.py @@ -27,7 +27,7 @@ from time import sleep from threading import Thread import sabnzbd -from sabnzbd.constants import Status, MAX_DECODE_QUEUE, LIMIT_DECODE_QUEUE, SABYENC_VERSION +from sabnzbd.constants import Status, MAX_DECODE_QUEUE, LIMIT_DECODE_QUEUE, SABYENC_VERSION_REQUIRED import sabnzbd.articlecache import sabnzbd.downloader import sabnzbd.nzbqueue @@ -43,12 +43,13 @@ except ImportError: try: import sabyenc - HAVE_SABYENC = True + SABYENC_ENABLED = True + SABYENC_VERSION = sabyenc.__version__ # Verify version - if sabyenc.__version__ != SABYENC_VERSION: + if SABYENC_VERSION != SABYENC_VERSION_REQUIRED: raise ImportError except ImportError: - HAVE_SABYENC = False + SABYENC_ENABLED = False class CrcError(Exception): @@ -210,7 +211,7 @@ class Decoder(Thread): YDEC_TRANS = ''.join([chr((i + 256 - 42) % 256) for i in xrange(256)]) def decode(article, data, raw_data): # Do we have SABYenc? Let it do all the work - if sabnzbd.decoder.HAVE_SABYENC: + if sabnzbd.decoder.SABYENC_ENABLED: decoded_data, output_filename, crc, crc_expected, crc_correct = sabyenc.decode_usenet_chunks(raw_data, article.bytes) # Assume it is yenc diff --git a/sabnzbd/downloader.py b/sabnzbd/downloader.py index 859afa1..dcc1aa4 100644 --- a/sabnzbd/downloader.py +++ b/sabnzbd/downloader.py @@ -202,7 +202,7 @@ class Downloader(Thread): # Initialize decoders, only 1 for non-SABYenc self.decoder_workers = [] - nr_decoders = cfg.nr_decoders() if sabnzbd.decoder.HAVE_SABYENC else 1 + nr_decoders = cfg.nr_decoders() if sabnzbd.decoder.SABYENC_ENABLED else 1 for i in range(nr_decoders): self.decoder_workers.append(Decoder(self.servers, self.decoder_queue)) diff --git a/sabnzbd/interface.py b/sabnzbd/interface.py index 9a614f8..fd5aa32 100644 --- a/sabnzbd/interface.py +++ b/sabnzbd/interface.py @@ -55,7 +55,7 @@ from sabnzbd.downloader import Downloader from sabnzbd.nzbqueue import NzbQueue import sabnzbd.wizard from sabnzbd.utils.servertests import test_nntp_server_dict -from sabnzbd.decoder import HAVE_YENC, HAVE_SABYENC +from sabnzbd.decoder import HAVE_YENC, SABYENC_ENABLED from sabnzbd.utils.sslinfo import ssl_version, ssl_protocols_labels from sabnzbd.utils.diskspeed import diskspeedmeasure from sabnzbd.utils.getperformance import getpystone @@ -1219,7 +1219,7 @@ class ConfigPage(object): conf['have_7zip'] = bool(sabnzbd.newsunpack.SEVEN_COMMAND) conf['have_cryptography'] = bool(sabnzbd.HAVE_CRYPTOGRAPHY) conf['have_yenc'] = HAVE_YENC - conf['have_sabyenc'] = HAVE_SABYENC + conf['have_sabyenc'] = SABYENC_ENABLED conf['have_mt_par2'] = sabnzbd.newsunpack.PAR2_MT conf['have_ssl_context'] = sabnzbd.HAVE_SSL_CONTEXT diff --git a/sabnzbd/newswrapper.py b/sabnzbd/newswrapper.py index e208e03..5f29803 100644 --- a/sabnzbd/newswrapper.py +++ b/sabnzbd/newswrapper.py @@ -414,7 +414,7 @@ class NewsWrapper(object): return (0, False, True) # Data is processed differently depending on C-yEnc version - if sabnzbd.decoder.HAVE_SABYENC: + if sabnzbd.decoder.SABYENC_ENABLED: # Append so we can do 1 join(), much faster than multiple! self.data.append(chunk)