Add support for Join sets where the parity protects the split files
[rarslave2.git] / PAR2Set / ExtractFirstBase.py
1 #!/usr/bin/env python
2 # vim: set ts=4 sts=4 sw=4 textwidth=92:
3
4 """
5 Holds the ExtractFirstBase class.
6 """
7
8 __author__    = "Ira W. Snyder (devel@irasnyder.com)"
9 __copyright__ = "Copyright (c) 2006,2007 Ira W. Snyder (devel@irasnyder.com)"
10 __license__   = "GNU GPL v2 (or, at your option, any later version)"
11
12 #    ExtractFirstBase.py
13 #
14 #    Copyright (C) 2006,2007  Ira W. Snyder (devel@irasnyder.com)
15 #
16 #    This program is free software; you can redistribute it and/or modify
17 #    it under the terms of the GNU General Public License as published by
18 #    the Free Software Foundation; either version 2 of the License, or
19 #    (at your option) any later version.
20 #
21 #    This program is distributed in the hope that it will be useful,
22 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
23 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24 #    GNU General Public License for more details.
25 #
26 #    You should have received a copy of the GNU General Public License
27 #    along with this program; if not, write to the Free Software
28 #    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
29
30 import logging
31 from subprocess import CalledProcessError
32 from PAR2Set import Base
33
34 class ExtractFirstBase(Base):
35
36     ############################################################################
37
38     def run(self):
39
40         # Extraction Stage
41         try:
42             self.extract ()
43         except (CalledProcessError, OSError):
44             logging.critical('Extraction stage failed for: %s' % self)
45             raise
46
47         self.updateFilesystemState()
48
49         # Repair Stage
50         try:
51             self.repair()
52         except (CalledProcessError, OSError):
53             logging.critical('Repair stage failed for: %s' % self)
54             raise
55
56         self.updateFilesystemState()
57
58         # Deletion Stage
59         try:
60             self.delete ()
61         except (CalledProcessError, OSError):
62             logging.critical('Deletion stage failed for: %s' % self)
63             raise
64
65         logging.info ('Successfully completed: %s' % self)
66
67     ############################################################################
68