Use exceptions for error handling
[rarslave2.git] / PAR2Set / Join.py
index 61a1c42..1dd680a 100644 (file)
@@ -75,28 +75,7 @@ class Join (PAR2Set.Base.Base):
 
                   This is done using the par2repair command by default"""
 
 
                   This is done using the par2repair command by default"""
 
-               PAR2_CMD = rsutil.common.config_get_value ('commands', 'par2repair')
-
-               # assemble the command
-               # par2repair -- PAR2 PAR2_EXTRA [JOIN_FILES]
-               command = "%s \"%s\" " % (PAR2_CMD, self.p2file)
-
-               for f in self.all_p2files:
-                       if f != self.p2file:
-                               command += "\"%s\" " % os.path.split (f)[1]
-
-               for f in self.find_joinfiles ():
-                       command += "\"%s\" " % os.path.split (f)[1]
-
-               # run the command
-               ret = rsutil.common.run_command (command, self.dir)
-
-               # check the result
-               if ret != 0:
-                       logging.critical ('PAR2 Check / Repair failed: %s' % self.p2file)
-                       return -rsutil.common.ECHECK
-
-               return rsutil.common.SUCCESS
+               rsutil.common.run_command(['par2repair'] + self.all_p2files + self.find_joinfiles(), self.dir)
 
        def find_deleteable_files (self):
                """Find all files which are deletable by using the regular expression from the
 
        def find_deleteable_files (self):
                """Find all files which are deletable by using the regular expression from the
@@ -123,20 +102,5 @@ class Join (PAR2Set.Base.Base):
                   This command ignores the extraction if file and todir+file are the same
                   file. This keeps things like mv working smoothly."""
 
                   This command ignores the extraction if file and todir+file are the same
                   file. This keeps things like mv working smoothly."""
 
-               NOEXTRACT_CMD = rsutil.common.config_get_value ('commands', 'noextract')
-
-               # Make sure that both files are not the same file. If they are, don't run at all.
-               # NOTE: os.path.samefile() doesn't exist on win32, so we can't use it.
-               if rsutil.common.full_abspath (file) == \
-                               rsutil.common.full_abspath (os.path.join (todir, file)):
-                       return rsutil.common.SUCCESS
-
-               cmd = NOEXTRACT_CMD % (file, todir)
-               ret = rsutil.common.run_command (cmd)
-
-               # Check error code
-               if ret != 0:
-                       return -rsutil.common.EEXTRACT
-
-               return rsutil.common.SUCCESS
-
+               # The Join type doesn't need any extraction
+               pass