[LOGGER] Switch to built-in logging class
[rarslave2.git] / PAR2Set / ExtractFirstBase.py
1 #!/usr/bin/env python
2 # vim: set ts=4 sts=4 sw=4 textwidth=92:
3
4 import logging
5 import PAR2Set
6 from RarslaveCommon import *
7
8 #
9 # This is another base class for types that must
10 # run the extraction routine before the repair routine
11 #
12 # It will detect sets like the following:
13 # X.par2
14 # X.vol0+1.par2
15 # X.vol1+2.par2
16 # X.part01.rar
17 # X.part02.rar
18 # X.part03.rar
19 #
20 # Where the PAR2 files protect a file named X.avi, but not the X.part01.rar
21 # (and other) files.
22 #
23
24 class PAR2Set_EXTRACTFIRST (PAR2Set.PAR2Set):
25
26         def runAll (self):
27
28                 # Extraction Stage
29                 ret = self.runExtract ()
30
31                 if ret != SUCCESS:
32                         logging.critical ('Extraction stage failed for: %s' % self.p2file)
33                         return -EEXTRACT
34
35                 self.update_matches ()
36
37                 # Repair Stage
38                 ret = self.runVerifyAndRepair ()
39
40                 if ret != SUCCESS:
41                         logging.critical ('Repair stage failed for: %s' % self.p2file)
42                         return -ECHECK
43
44                 self.update_matches ()
45
46                 # Deletion Stage
47                 ret = self.runDelete ()
48
49                 if ret != SUCCESS:
50                         logging.critical ('Deletion stage failed for: %s' % self.p2file)
51                         return -EDELETE
52
53                 logging.info ('Successfully completed: %s' % self.p2file)
54                 return SUCCESS
55