mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-20 13:23:18 -07:00
make os handling the same
This commit is contained in:
parent
4071a07c4a
commit
9d6f8ee418
1 changed files with 10 additions and 21 deletions
|
@ -52,7 +52,7 @@ def extract(dirpath, file, outputDestination):
|
||||||
Logger.error("EXTRACTOR: Couldnt find 7-zip, Exiting")
|
Logger.error("EXTRACTOR: Couldnt find 7-zip, Exiting")
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
else:
|
else:
|
||||||
cmd_7zip = [sevenzipLocation, 'x -y']
|
cmd_7zip = [sevenzipLocation, "x", "-y"]
|
||||||
ext_7zip = [".rar",".zip",".tar.gz","tgz",".tar.bz2",".tbz",".tar.lzma",".tlz",".7z",".xz"]
|
ext_7zip = [".rar",".zip",".tar.gz","tgz",".tar.bz2",".tbz",".tar.lzma",".tlz",".7z",".xz"]
|
||||||
EXTRACT_COMMANDS = dict.fromkeys(ext_7zip, cmd_7zip)
|
EXTRACT_COMMANDS = dict.fromkeys(ext_7zip, cmd_7zip)
|
||||||
# Using unix
|
# Using unix
|
||||||
|
@ -109,25 +109,14 @@ def extract(dirpath, file, outputDestination):
|
||||||
Logger.debug("Extracting %s %s %s %s", cmd[0], cmd[1], filePath, outputDestination)
|
Logger.debug("Extracting %s %s %s %s", cmd[0], cmd[1], filePath, outputDestination)
|
||||||
pwd = os.getcwd() # Get our Present Working Directory
|
pwd = os.getcwd() # Get our Present Working Directory
|
||||||
os.chdir(outputDestination) # Not all unpack commands accept full paths, so just extract into this directory
|
os.chdir(outputDestination) # Not all unpack commands accept full paths, so just extract into this directory
|
||||||
if os.name == 'nt': # Windows needs quotes around directory structure
|
try: # now works same for nt and *nix
|
||||||
try:
|
cmd.append(filePath) # add filePath to final cmd arg.
|
||||||
run = "\"" + cmd[0] + "\" " + cmd[1] + " \"" + filePath + "\"" # Windows needs quotes around directories
|
res = call(cmd) # should extract files fine.
|
||||||
res = call(run)
|
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:
|
Logger.error("EXTRACTOR: Extraction failed for %s. 7zip result was %s", filePath, res)
|
||||||
Logger.info("EXTRACTOR: Extraction failed for %s. 7zip result was %s", filePath, res)
|
except:
|
||||||
except:
|
Logger.error("EXTRACTOR: Extraction failed for %s. Could not call command %s %s %s %s", filePath, cmd[0], cmd[1], filePath)
|
||||||
Logger.error("EXTRACTOR: Extraction failed for %s. Could not call command %s", filePath, run)
|
|
||||||
else:
|
|
||||||
try:
|
|
||||||
cmd.append(filePath) # add filePath to final cmd arg.
|
|
||||||
res = call(cmd) # should extract files fine.
|
|
||||||
if res == 0:
|
|
||||||
Logger.info("EXTRACTOR: Extraction was successful for %s to %s", filePath, outputDestination)
|
|
||||||
else:
|
|
||||||
Logger.error("EXTRACTOR: Extraction failed for %s. 7zip result was %s", filePath, res)
|
|
||||||
except:
|
|
||||||
Logger.error("EXTRACTOR: Extraction failed for %s. Could not call command %s %s %s %s", filePath, cmd[0], cmd[1], filePath)
|
|
||||||
os.chdir(pwd) # Go back to our Original Working Directory
|
os.chdir(pwd) # Go back to our Original Working Directory
|
||||||
return True
|
return True
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue