fix command + arg passing.

might not be the prettiest way... but it works.
This commit is contained in:
Clinton Hall 2013-02-28 18:57:43 -08:00
commit 06d1ea82e3

View file

@ -63,13 +63,13 @@ def extract(dirpath, file, outputDestination):
# ".bz2": ["bzip2", "-d --keep"], # ".bz2": ["bzip2", "-d --keep"],
EXTRACT_COMMANDS = { EXTRACT_COMMANDS = {
".rar": ["unrar", "x -y"], ".rar": ["unrar", "x", "-o+", "-y"],
".tar": ["tar", "-xf"], ".tar": ["tar", "-xf"],
".zip": ["unzip", ""], ".zip": ["unzip"],
".tar.gz": ["tar", "-xzf"], ".tgz": ["tar", "-xzf"], ".tar.gz": ["tar", "-xzf"], ".tgz": ["tar", "-xzf"],
".tar.bz2": ["tar", "-xjf"], ".tbz": ["tar", "-xjf"], ".tar.bz2": ["tar", "-xjf"], ".tbz": ["tar", "-xjf"],
".tar.lzma": ["tar", "--lzma -xf"], ".tlz": ["tar", "--lzma -xf"], ".tar.lzma": ["tar", "--lzma", "-xf"], ".tlz": ["tar", "--lzma", "-xf"],
".tar.xz": ["tar", "--xz -xf"], ".txz": ["tar", "--xz -xf"], ".tar.xz": ["tar", "--xz", "-xf"], ".txz": ["tar", "--xz", "-xf"],
".7z": ["7zr", "x"], ".7z": ["7zr", "x"],
} }
# Test command exists and if not, remove # Test command exists and if not, remove
@ -119,10 +119,14 @@ def extract(dirpath, file, outputDestination):
Logger.error("EXTRACTOR: Extraction failed for %s. Could not call command %s", filePath, run) Logger.error("EXTRACTOR: Extraction failed for %s. Could not call command %s", filePath, run)
else: else:
try: try:
if cmd[1] == "": # If calling unzip, we dont want to pass the "" if len(cmd) == 1: # If calling unzip
res = call([cmd[0], filePath]) res = call([cmd[0], filePath])
else: elif len(cmd) == 2: # command + 1 arg
res = call([cmd[0], cmd[1], filePath]) res = call([cmd[0], cmd[1], filePath])
elif len(cmd) == 3: # command + 2 args
res = call([cmd[0], cmd[1], cmd[2], filePath])
else: # If calling unrar, command + 3 args
res = call([cmd[0], cmd[1], cmd[2], cmd[3], filePath])
if res == 0: if res == 0:
Logger.info("EXTRACTOR: Extraction was successful for %s to %s", filePath, outputDestination) Logger.info("EXTRACTOR: Extraction was successful for %s to %s", filePath, outputDestination)
else: else: