[RARSLAVE] Fix exception syntax
[rarslave2.git] / rarslave.py
index 1969ce2..27db583 100644 (file)
@@ -5,7 +5,7 @@ VERSION="2.0.0"
 PROGRAM="rarslave2"
 
 import re, os, sys, optparse
-import par2parser
+import Par2Parser
 import RarslaveConfig
 import RarslaveLogger
 
@@ -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, OSError, OverflowError):
+               parsed_matches = []
+               logger.addMessage ('Bad par2 file: %s' % p2file, RarslaveLogger.MessageType.Fatal)
 
        return name_matches + parsed_matches
 
@@ -277,9 +281,9 @@ def find_extraction_heads (dir, files):
                for f in p2files:
                        done = False
                        try:
-                               prot_files = par2parser.get_protected_files (dir, f)
+                               prot_files = Par2Parser.get_protected_files (dir, f)
                                done = True
-                       except: #FIXME: add the actual exceptions
+                       except (EnvironmentError, OverflowError, OSError):
                                logger.addMessage ('Error parsing PAR2 file: %s', f)
                                continue
 
@@ -295,7 +299,7 @@ def find_extraction_heads (dir, files):
        # Make sure we found the type
        if extractor == None:
                logger.addMessage ('Not able to find an extractor for this type of set: %s' % p2files[0],
-                               RarslaveLogger.MessageType.Fatal)
+                               RarslaveLogger.MessageType.Verbose)
 
                # No-heads here, but it's better than failing completely
                extractor = RarslaveExtractor (TYPE_NOEXTRACT)
@@ -415,11 +419,12 @@ def delete_list (dir, files, interactive=False):
 
        done = False
        valid_y = ['Y', 'YES']
-       valid_n = ['N', 'NO']
+       valid_n = ['N', 'NO', '']
 
        if interactive:
                while not done:
                        print 'Do you want to delete the following?:'
+                       printlist (files)
                        s = raw_input ('Delete [y/N]: ').upper()
 
                        if s in valid_y + valid_n: