From: Ira W. Snyder Date: Thu, 28 Dec 2006 04:00:17 +0000 (-0800) Subject: [RARSLAVE] Catch exceptions from par2parser X-Git-Tag: v2.0.0~31 X-Git-Url: https://irasnyder.com/gitweb/?a=commitdiff_plain;h=39fb31847ce65f0369c11927ca4b349897a71001;p=rarslave2.git [RARSLAVE] Catch exceptions from par2parser Add try / except blocks to catch exceptions that happen in the par2parser class. Signed-off-by: Ira W. Snyder --- diff --git a/rarslave.py b/rarslave.py index 2096a97..8caf29e 100644 --- a/rarslave.py +++ b/rarslave.py @@ -208,7 +208,11 @@ def find_likely_files (dir, p2file): regex = re.compile ('^%s.*$' % (ename, )) name_matches = [f for f in os.listdir (dir) if regex.match (f)] - parsed_matches = par2parser.get_protected_files (dir, p2file) + try: + parsed_matches = par2parser.get_protected_files (dir, p2file) + except EnvironmentError: + parsed_matches = [] + logger.addMessage ('Bad par2 file: %s' % p2file, RarslaveLogger.MessageType.Fatal) return name_matches + parsed_matches @@ -279,7 +283,7 @@ def find_extraction_heads (dir, files): try: prot_files = par2parser.get_protected_files (dir, f) done = True - except: #FIXME: add the actual exceptions + except EnvironmentError: logger.addMessage ('Error parsing PAR2 file: %s', f) continue