mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-07-16 02:02:53 -07:00
add chp (create hidden process)
This commit is contained in:
parent
1d5ff21e59
commit
c31abfe990
1 changed files with 6 additions and 6 deletions
|
@ -45,14 +45,16 @@ def extract(filePath, outputDestination):
|
||||||
else:
|
else:
|
||||||
platform = 'x86'
|
platform = 'x86'
|
||||||
if not os.path.dirname(sys.argv[0]):
|
if not os.path.dirname(sys.argv[0]):
|
||||||
|
chplocation = os.path.normpath(os.path.join(os.getcwd(), 'extractor/bin/chp.exe'))
|
||||||
sevenzipLocation = os.path.normpath(os.path.join(os.getcwd(), 'extractor/bin/' + platform + '/7z.exe'))
|
sevenzipLocation = os.path.normpath(os.path.join(os.getcwd(), 'extractor/bin/' + platform + '/7z.exe'))
|
||||||
else:
|
else:
|
||||||
|
chplocation = os.path.normpath(os.path.join(os.path.dirname(sys.argv[0]), 'extractor/bin/chp.exe'))
|
||||||
sevenzipLocation = os.path.normpath(os.path.join(os.path.dirname(sys.argv[0]), 'extractor/bin/' + platform + '/7z.exe'))
|
sevenzipLocation = os.path.normpath(os.path.join(os.path.dirname(sys.argv[0]), 'extractor/bin/' + platform + '/7z.exe'))
|
||||||
if not os.path.exists(sevenzipLocation):
|
if not os.path.exists(sevenzipLocation):
|
||||||
Logger.error("EXTRACTOR: Could not find 7-zip, Exiting")
|
Logger.error("EXTRACTOR: Could not find 7-zip, Exiting")
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
else:
|
else:
|
||||||
cmd_7zip = [sevenzipLocation, "x", "-y"]
|
cmd_7zip = [chplocation, 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
|
||||||
|
@ -110,14 +112,12 @@ 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.
|
||||||
p = Popen(cmd, stdout=PIPE, stderr=PIPE) # should extract files fine.
|
p = Popen(cmd)) # should extract files fine.
|
||||||
out, err = p.communicate()
|
res = p.wait()
|
||||||
res = p.returncode
|
if res >= 0: # for windows chp returns process id if successful or -1*Error code. Linus returns 0 for successful.
|
||||||
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