Browse Source

Fix little problem in extension detection and fix some PyLint complaints.

pull/156/head
shypike 11 years ago
parent
commit
987a64d3a4
  1. 16
      sabnzbd/assembler.py

16
sabnzbd/assembler.py

@ -50,7 +50,7 @@ from sabnzbd.encoding import latin1, unicoder, is_utf8
class Assembler(Thread): class Assembler(Thread):
do = None # Link to the instance of this method do = None # Link to the instance of this method
def __init__ (self, queue = None): def __init__(self, queue=None):
Thread.__init__(self) Thread.__init__(self)
if queue: if queue:
@ -101,7 +101,7 @@ class Assembler(Thread):
# Pause without saving # Pause without saving
sabnzbd.downloader.Downloader.do.pause(save=False) sabnzbd.downloader.Downloader.do.pause(save=False)
except: except:
logging.error('Fatal error in Assembler', exc_info = True) logging.error('Fatal error in Assembler', exc_info=True)
break break
nzf.remove_admin() nzf.remove_admin()
@ -122,7 +122,7 @@ class Assembler(Thread):
import sabnzbd.nzbqueue import sabnzbd.nzbqueue
sabnzbd.nzbqueue.NzbQueue.do.end_job(nzo) sabnzbd.nzbqueue.NzbQueue.do.end_job(nzo)
unwanted = rar_contains_unwanted_file(nzo, filepath) unwanted = rar_contains_unwanted_file(filepath)
if unwanted: if unwanted:
logging.warning(Ta('WARNING: In "%s" unwanted extension in RAR file. Unwanted file is %s '), latin1(nzo.final_name), unwanted) logging.warning(Ta('WARNING: In "%s" unwanted extension in RAR file. Unwanted file is %s '), latin1(nzo.final_name), unwanted)
if cfg.action_on_unwanted_extensions() == 1: if cfg.action_on_unwanted_extensions() == 1:
@ -144,7 +144,7 @@ class Assembler(Thread):
def _assemble(nzf, path, dupe): def _assemble(nzf, path, dupe):
if os.path.exists(path): if os.path.exists(path):
unique_path = get_unique_path(path, create_dir = False) unique_path = get_unique_path(path, create_dir=False)
if dupe: if dupe:
path = unique_path path = unique_path
else: else:
@ -255,7 +255,7 @@ def GetMD5Hashes(fname, force=False):
table = {} table = {}
except: except:
logging.debug('QuickCheck parser crashed in file %s', fname) logging.debug('QuickCheck parser crashed in file %s', fname)
logging.info('Traceback: ', exc_info = True) logging.info('Traceback: ', exc_info=True)
table = {} table = {}
f.close() f.close()
@ -338,12 +338,12 @@ def check_encrypted_rar(nzo, filepath):
return encrypted return encrypted
def rar_contains_unwanted_file(nzo, filepath): def rar_contains_unwanted_file(filepath):
# checks for unwanted extensions in the rar file 'filepath' # checks for unwanted extensions in the rar file 'filepath'
# ... unwanted extensions are defined in global variable cfg.unwanted_extensions() # ... unwanted extensions are defined in global variable cfg.unwanted_extensions()
# returns False if no unwanted extensions are found in the rar file # returns False if no unwanted extensions are found in the rar file
# returns name of file if unwanted extension is found in the rar file # returns name of file if unwanted extension is found in the rar file
unwanted = False unwanted = None
if is_rarfile(filepath): if is_rarfile(filepath):
#logging.debug('rar file to check: %s',filepath) #logging.debug('rar file to check: %s',filepath)
#logging.debug('unwanted extensions are: %s', cfg.unwanted_extensions()) #logging.debug('unwanted extensions are: %s', cfg.unwanted_extensions())
@ -354,7 +354,7 @@ def rar_contains_unwanted_file(nzo, filepath):
logging.debug('file in rar file: %s', somefile) logging.debug('file in rar file: %s', somefile)
if os.path.splitext(somefile)[1].replace('.', '').lower() in cfg.unwanted_extensions(): if os.path.splitext(somefile)[1].replace('.', '').lower() in cfg.unwanted_extensions():
logging.debug('Unwanted file %s', somefile) logging.debug('Unwanted file %s', somefile)
unwanted = True unwanted = somefile
zf.close() zf.close()
except: except:
logging.debug('RAR file %s cannot be inspected.', filepath) logging.debug('RAR file %s cannot be inspected.', filepath)

Loading…
Cancel
Save