# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import logging
-import PAR2Set.Base
-import rsutil.common
+from subprocess import CalledProcessError
+from PAR2Set import Base
-class ExtractFirstBase (PAR2Set.Base.Base):
- """Base class for PAR2Set types which run the extraction routine before
- the repair routine"""
+class ExtractFirstBase(Base):
- def runAll (self):
- """Run the extraction, repair, and delete stages"""
+ ############################################################################
- # Extraction Stage
- ret = self.runExtract ()
+ def run(self):
- if ret != rsutil.common.SUCCESS:
- logging.critical ('Extraction stage failed for: %s' % self.p2file)
- return -rsutil.common.EEXTRACT
+ # Extraction Stage
+ try:
+ self.extract ()
+ except (CalledProcessError, OSError):
+ logging.critical('Extraction stage failed for: %s' % self)
+ raise
- self.update_matches ()
+ self.updateFilesystemState()
- # Repair Stage
- ret = self.runVerifyAndRepair ()
+ # Repair Stage
+ try:
+ self.repair()
+ except (CalledProcessError, OSError):
+ logging.critical('Repair stage failed for: %s' % self)
+ raise
- if ret != rsutil.common.SUCCESS:
- logging.critical ('Repair stage failed for: %s' % self.p2file)
- return -rsutil.common.ECHECK
+ self.updateFilesystemState()
- self.update_matches ()
+ # Deletion Stage
+ try:
+ self.delete ()
+ except (CalledProcessError, OSError):
+ logging.critical('Deletion stage failed for: %s' % self)
+ raise
- # Deletion Stage
- ret = self.runDelete ()
+ logging.info ('Successfully completed: %s' % self)
- if ret != rsutil.common.SUCCESS:
- logging.critical ('Deletion stage failed for: %s' % self.p2file)
- return -rsutil.common.EDELETE
-
- logging.info ('Successfully completed: %s' % self.p2file)
- return rsutil.common.SUCCESS
+ ############################################################################