mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-19 21:03:14 -07:00
Suppress windows open on extraction. Fixes #97
Uses Popen with stdout and stderr redirection
This commit is contained in:
parent
7a523ce38d
commit
18c7961ef1
1 changed files with 5 additions and 2 deletions
|
@ -2,7 +2,7 @@ import os
|
||||||
import sys
|
import sys
|
||||||
sys.path.insert(0, os.path.join(os.path.dirname(sys.argv[0]),'autoProcess/'))
|
sys.path.insert(0, os.path.join(os.path.dirname(sys.argv[0]),'autoProcess/'))
|
||||||
import logging
|
import logging
|
||||||
from subprocess import call
|
from subprocess import call, Popen, PIPE
|
||||||
from nzbToMediaUtil import create_destination
|
from nzbToMediaUtil import create_destination
|
||||||
|
|
||||||
|
|
||||||
|
@ -110,11 +110,14 @@ def extract(filePath, outputDestination):
|
||||||
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
|
||||||
try: # now works same for nt and *nix
|
try: # now works same for nt and *nix
|
||||||
cmd.append(filePath) # add filePath to final cmd arg.
|
cmd.append(filePath) # add filePath to final cmd arg.
|
||||||
res = call(cmd) # should extract files fine.
|
p = Popen(cmd, stdout=PIPE, stderr=PIPE) # should extract files fine.
|
||||||
|
out, err = p.communicate()
|
||||||
|
res = p.returncode
|
||||||
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.error("EXTRACTOR: Extraction failed for %s. 7zip result was %s", filePath, res)
|
||||||
|
Logger.error("EXTRACTOR: 7zip output was: %s. 7zip error was %s", out, err)
|
||||||
except:
|
except:
|
||||||
Logger.error("EXTRACTOR: Extraction failed for %s. Could not call command %s", filePath, cmd)
|
Logger.error("EXTRACTOR: Extraction failed for %s. Could not call command %s", filePath, cmd)
|
||||||
os.chdir(pwd) # Go back to our Original Working Directory
|
os.chdir(pwd) # Go back to our Original Working Directory
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue