#!/usr/bin/env python
# vim: set ts=4 sts=4 sw=4 textwidth=92:
-import logging
-import PAR2Set.Base
-import rsutil.common
+"""
+Holds the ExtractFirstBase class.
+"""
+
+__author__ = "Ira W. Snyder (devel@irasnyder.com)"
+__copyright__ = "Copyright (c) 2006,2007 Ira W. Snyder (devel@irasnyder.com)"
+__license__ = "GNU GPL v2 (or, at your option, any later version)"
+# ExtractFirstBase.py
#
-# This is another base class for types that must
-# run the extraction routine before the repair routine
+# Copyright (C) 2006,2007 Ira W. Snyder (devel@irasnyder.com)
#
-# It will detect sets like the following:
-# X.par2
-# X.vol0+1.par2
-# X.vol1+2.par2
-# X.part01.rar
-# X.part02.rar
-# X.part03.rar
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
#
-# Where the PAR2 files protect a file named X.avi, but not the X.part01.rar
-# (and other) files.
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-class ExtractFirstBase (PAR2Set.Base.Base):
+import logging
+from subprocess import CalledProcessError
+from PAR2Set import Base
- def runAll (self):
+class ExtractFirstBase(Base):
- # Extraction Stage
- ret = self.runExtract ()
+ ############################################################################
- if ret != SUCCESS:
- logging.critical ('Extraction stage failed for: %s' % self.p2file)
- return -EEXTRACT
+ def run(self):
- self.update_matches ()
+ # Extraction Stage
+ try:
+ self.extract ()
+ except (CalledProcessError, OSError):
+ logging.critical('Extraction stage failed for: %s' % self)
+ raise
- # Repair Stage
- ret = self.runVerifyAndRepair ()
+ self.updateFilesystemState()
- if ret != SUCCESS:
- logging.critical ('Repair stage failed for: %s' % self.p2file)
- return -ECHECK
+ # Repair Stage
+ try:
+ self.repair()
+ except (CalledProcessError, OSError):
+ logging.critical('Repair stage failed for: %s' % self)
+ raise
- self.update_matches ()
+ self.updateFilesystemState()
- # Deletion Stage
- ret = self.runDelete ()
+ # Deletion Stage
+ try:
+ self.delete ()
+ except (CalledProcessError, OSError):
+ logging.critical('Deletion stage failed for: %s' % self)
+ raise
- if ret != SUCCESS:
- logging.critical ('Deletion stage failed for: %s' % self.p2file)
- return -EDELETE
+ logging.info ('Successfully completed: %s' % self)
- logging.info ('Successfully completed: %s' % self.p2file)
- return SUCCESS
+ ############################################################################