[RARSLAVE] Catch exceptions from par2parser
[rarslave2.git] / rarslave.py
index 1969ce2..8caf29e 100644 (file)
@@ -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)]
        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
 
 
        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
                        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
 
                                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],
        # 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)
 
                # No-heads here, but it's better than failing completely
                extractor = RarslaveExtractor (TYPE_NOEXTRACT)
@@ -420,6 +424,7 @@ def delete_list (dir, files, interactive=False):
        if interactive:
                while not done:
                        print 'Do you want to delete the following?:'
        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:
                        s = raw_input ('Delete [y/N]: ').upper()
 
                        if s in valid_y + valid_n: