+ types = (
+ PAR2Set.Join,
+ PAR2Set.ZIP,
+ PAR2Set.OldRAR,
+ PAR2Set.NewRAR,
+ PAR2Set.ExtractFirstOldRAR,
+ PAR2Set.ExtractFirstNewRAR,
+ PAR2Set.NoExtract,
+ )
+
+ detected = False
+
+ # Try to detect each type in turn
+ for t in types:
+ try:
+ instance = t(cs, options)
+ detected = True
+ logging.debug('%s detected for %s' % (t.__name__, cs.parityFile))
+ except TypeError:
+ logging.debug('%s not detected for %s' % (t.__name__, cs.parityFile))
+ continue
+
+ # We detected something, try to run it
+ try:
+ instance.run()
+ logging.info('Success: %s' % instance)
+
+ # Leave early, we're done
+ return
+ except (OSError, CalledProcessError):
+ logging.critical('Failure: %s' % instance)
+
+ # Check that at least one detection worked
+ if not detected:
+ logging.critical('Detection failed: %s' % cs.parityFile)
+ logging.debug('The following information will help to create a detector')
+ logging.debug('===== BEGIN CompareSet RAW INFO =====')
+ logging.debug(str(cs))
+ logging.debug('===== END CompareSet RAW INFO =====')
+
+ # If we got here, either the detection didn't work or the run itself didn't
+ # work, so print out the message telling the user that we were unsuccessful
+ logging.critical('Unsuccessful: %s' % cs.parityFile)
+
+################################################################################
+
+def runDirectory(directory, files, options):
+
+ logging.debug('Running in directory: %s' % directory)
+ sets = findUniqueSets(directory, files)
+
+ for cs in sets:
+ try:
+ runEachType(cs, options)
+ except:
+ logging.error('Unknown Exception: %s' % cs.parityFile)
+
+################################################################################
+
+def main ():