# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+import re
import os
import logging
import PAR2Set.Base
This is done using the par2repair command by default"""
- PAR2_CMD = rsutil.common.config_get_value ('commands', 'par2repair')
+ rsutil.common.run_command(['par2repair'] + self.all_p2files + self.find_joinfiles(), self.dir)
- # assemble the command
- # par2repair -- PAR2 PAR2_EXTRA [JOIN_FILES]
- command = "%s \"%s\" " % (PAR2_CMD, self.p2file)
+ def find_deleteable_files (self):
+ """Find all files which are deletable by using the regular expression from the
+ configuration file"""
- for f in self.all_p2files:
- if f != self.p2file:
- command += "\"%s\" " % os.path.split (f)[1]
+ DELETE_REGEX = rsutil.common.config_get_value ('regular expressions', 'delete_regex')
+ dregex = re.compile (DELETE_REGEX, re.IGNORECASE)
- for f in self.find_joinfiles ():
- command += "\"%s\" " % os.path.split (f)[1]
-
- # run the command
- ret = rsutil.common.run_command (command, self.dir)
-
- # check the result
- if ret != 0:
- logging.critical ('PAR2 Check / Repair failed: %s' % self.p2file)
- return -rsutil.common.ECHECK
-
- return rsutil.common.SUCCESS
+ return [f for f in self.all_files if dregex.match (f) and \
+ f not in self.prot_matched_files]
def find_extraction_heads (self):
"""Find the extraction heads. Since this should not be an extractable set,
This command ignores the extraction if file and todir+file are the same
file. This keeps things like mv working smoothly."""
- NOEXTRACT_CMD = rsutil.common.config_get_value ('commands', 'noextract')
-
- # Make sure that both files are not the same file. If they are, don't run at all.
- if os.path.samefile (file, os.path.join (todir, file)):
- return rsutil.common.SUCCESS
-
- cmd = NOEXTRACT_CMD % (file, todir)
- ret = rsutil.common.run_command (cmd)
-
- # Check error code
- if ret != 0:
- return -rsutil.common.EEXTRACT
-
- return rsutil.common.SUCCESS
-
+ # The Join type doesn't need any extraction
+ pass