#!/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
+
+import logging
+import PAR2Set.Base
+import rsutil.common
class ExtractFirstBase (PAR2Set.Base.Base):
+ """Base class for PAR2Set types which run the extraction routine before
+ the repair routine"""
def runAll (self):
+ """Run the extraction, repair, and delete stages"""
# Extraction Stage
- ret = self.runExtract ()
-
- if ret != SUCCESS:
- logging.critical ('Extraction stage failed for: %s' % self.p2file)
- return -EEXTRACT
+ try:
+ self.runExtract()
+ except (RuntimeError, OSError):
+ logging.critical('Extraction stage failed for: %s' % self.p2file)
+ raise
self.update_matches ()
# Repair Stage
- ret = self.runVerifyAndRepair ()
-
- if ret != SUCCESS:
- logging.critical ('Repair stage failed for: %s' % self.p2file)
- return -ECHECK
+ try:
+ self.runVerifyAndRepair()
+ except (RuntimeError, OSError):
+ logging.critical('Repair stage failed for: %s' % self.p2file)
+ raise
self.update_matches ()
# Deletion Stage
- ret = self.runDelete ()
-
- if ret != SUCCESS:
- logging.critical ('Deletion stage failed for: %s' % self.p2file)
- return -EDELETE
+ try:
+ self.runDelete()
+ except (RuntimeError, OSError):
+ logging.critical('Deletion stage failed for: %s' % self.p2file)
+ raise
logging.info ('Successfully completed: %s' % self.p2file)
- return SUCCESS