-
-
-class RarslaveRepairer (object):
- # Verify (and repair) the set
- # Make sure it worked, otherwise clean up and return failure
-
- def __init__ (self, dir, file, join=False):
- self.dir = dir # the directory containing the par2 file
- self.file = file # the par2 file
- self.join = join # True if the par2 set is 001 002 ...
-
- assert os.path.isdir (dir)
- assert os.path.isfile (os.path.join (dir, file))
-
- def checkAndRepair (self):
- # Form the command:
- # par2repair -- PAR2 PAR2_EXTRA [JOIN_FILES]
- PAR2_CMD = config.get_value ('commands', 'par2repair')
-
- # Get set up
- basename = get_basename (self.file)
- all_files = find_likely_files (basename, self.dir)
- all_files.sort ()
- par2_files = find_par2_files (all_files)
-
- # assemble the command
- command = "%s \"%s\" " % (PAR2_CMD, self.file)
-
- for f in par2_files:
- if f != self.file:
- command += "\"%s\" " % os.path.split (f)[1]
-
- if self.join:
- for f in all_files:
- if f not in par2_files:
- command += "\"%s\" " % os.path.split (f)[1]
-
- # run the command
- ret = run_command (command, self.dir)
-
- # check the result
- if ret != 0:
- logger.addMessage ('PAR2 Check / Repair failed: %s' % self.file, RarslaveLogger.MessageType.Fatal)
- return -ECHECK
-