[LOGGER] Switch to built-in logging class
[rarslave2.git] / PAR2Set.py
index 323fc24..e58cc16 100644 (file)
@@ -7,6 +7,7 @@ import Par2Parser
 
 import re
 import os
+import logging
 
 # This is a fairly generic class which does all of the major things that a PAR2
 # set will need to have done to be verified and extracted. For most "normal" types
@@ -87,7 +88,7 @@ class PAR2Set (object):
 
                # check the result
                if ret != 0:
-                       fatalMessage ('PAR2 Check / Repair failed: %s' % self.p2file)
+                       logging.critical ('PAR2 Check / Repair failed: %s' % self.p2file)
                        return -ECHECK
 
                return SUCCESS
@@ -123,9 +124,9 @@ class PAR2Set (object):
                for f in files:
                        try:
                                os.remove (os.path.join (dir, f))
-                               debugMessage ('Deleteing: %s' % os.path.join (dir, f))
+                               logging.debug ('Deleteing: %s' % os.path.join (dir, f))
                        except:
-                               fatalMessage ('Failed to delete: %s' % os.path.join (dir, f))
+                               logging.error ('Failed to delete: %s' % os.path.join (dir, f))
                                return -EDELETE
 
                return SUCCESS
@@ -143,7 +144,7 @@ class PAR2Set (object):
                ret = self.runVerifyAndRepair ()
 
                if ret != SUCCESS:
-                       fatalMessage ('Repair stage failed for: %s' % self.p2file)
+                       logging.critical ('Repair stage failed for: %s' % self.p2file)
                        return -ECHECK
 
                self.update_matches ()
@@ -152,7 +153,7 @@ class PAR2Set (object):
                ret = self.runExtract ()
 
                if ret != SUCCESS:
-                       fatalMessage ('Extraction stage failed for: %s' % self.p2file)
+                       logging.critical ('Extraction stage failed for: %s' % self.p2file)
                        return -EEXTRACT
 
                self.update_matches ()
@@ -161,10 +162,10 @@ class PAR2Set (object):
                ret = self.runDelete ()
 
                if ret != SUCCESS:
-                       fatalMessage ('Deletion stage failed for: %s' % self.p2file)
+                       logging.critical ('Deletion stage failed for: %s' % self.p2file)
                        return -EDELETE
 
-               normalMessage ('Successfully completed: %s' % self.p2file)
+               logging.info ('Successfully completed: %s' % self.p2file)
                return SUCCESS
 
        def safe_create_directory (self, dir):
@@ -176,9 +177,9 @@ class PAR2Set (object):
 
                try:
                        os.makedirs (dir)
-                       verboseMessage ('Created directory: %s' % dir)
+                       logging.info ('Created directory: %s' % dir)
                except OSError:
-                       fatalMessage ('FAILED to create directory: %s' % dir)
+                       logging.critical ('FAILED to create directory: %s' % dir)
                        return -ECREATE
 
                return SUCCESS
@@ -200,11 +201,11 @@ class PAR2Set (object):
                for h in self.find_extraction_heads ():
                        full_head = full_abspath (os.path.join (self.dir, h))
                        ret = self.extraction_function (full_head, todir)
-                       debugMessage ('Extraction Function returned: %d' % ret)
+                       logging.debug ('Extraction Function returned: %d' % ret)
 
                        # Check error code
                        if ret != SUCCESS:
-                               fatalMessage ('Failed extracting: %s' % h)
+                               logging.critical ('Failed extracting: %s' % h)
                                return -EEXTRACT
 
                return SUCCESS