mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-21 05:43:16 -07:00
exit extractor as failed if archives not extracted. Fixes #488
This commit is contained in:
parent
896107591f
commit
385b96d2d6
1 changed files with 15 additions and 13 deletions
|
@ -5,6 +5,7 @@ import nzbtomedia
|
||||||
from subprocess import call, Popen
|
from subprocess import call, Popen
|
||||||
|
|
||||||
def extract(filePath, outputDestination):
|
def extract(filePath, outputDestination):
|
||||||
|
success = 0
|
||||||
# Using Windows
|
# Using Windows
|
||||||
if platform.system() == 'Windows':
|
if platform.system() == 'Windows':
|
||||||
chplocation = nzbtomedia.os.path.join(nzbtomedia.PROGRAM_DIR, 'nzbtomedia/extractor/bin/chp.exe')
|
chplocation = nzbtomedia.os.path.join(nzbtomedia.PROGRAM_DIR, 'nzbtomedia/extractor/bin/chp.exe')
|
||||||
|
@ -94,12 +95,12 @@ def extract(filePath, outputDestination):
|
||||||
cmd2.append("-p-") # don't prompt for password.
|
cmd2.append("-p-") # don't prompt for password.
|
||||||
p = Popen(cmd2) # should extract files fine.
|
p = Popen(cmd2) # should extract files fine.
|
||||||
res = p.wait()
|
res = p.wait()
|
||||||
if (
|
if (res >= 0 and os.name == 'nt') or res == 0: # for windows chp returns process id if successful or -1*Error code. Linux returns 0 for successful.
|
||||||
res >= 0 and os.name == 'nt') or res == 0: # for windows chp returns process id if successful or -1*Error code. Linux returns 0 for successful.
|
|
||||||
nzbtomedia.logger.info("EXTRACTOR: Extraction was successful for %s to %s" % (filePath, outputDestination))
|
nzbtomedia.logger.info("EXTRACTOR: Extraction was successful for %s to %s" % (filePath, outputDestination))
|
||||||
|
success = 1
|
||||||
elif len(passwords) > 0:
|
elif len(passwords) > 0:
|
||||||
nzbtomedia.logger.info("EXTRACTOR: Attempting to extract with passwords")
|
nzbtomedia.logger.info("EXTRACTOR: Attempting to extract with passwords")
|
||||||
pass_success = int(0)
|
success = 0
|
||||||
for password in passwords:
|
for password in passwords:
|
||||||
if password == "": # if edited in windows or otherwise if blank lines.
|
if password == "": # if edited in windows or otherwise if blank lines.
|
||||||
continue
|
continue
|
||||||
|
@ -109,22 +110,23 @@ def extract(filePath, outputDestination):
|
||||||
cmd2.append(passcmd)
|
cmd2.append(passcmd)
|
||||||
p = Popen(cmd2) # should extract files fine.
|
p = Popen(cmd2) # should extract files fine.
|
||||||
res = p.wait()
|
res = p.wait()
|
||||||
if (
|
if (res >= 0 and platform == 'Windows') or res == 0:
|
||||||
res >= 0 and platform == 'Windows') or res == 0: # for windows chp returns process id if successful or -1*Error code. Linux returns 0 for successful.
|
|
||||||
nzbtomedia.logger.info("EXTRACTOR: Extraction was successful for %s to %s using password: %s" % (
|
nzbtomedia.logger.info("EXTRACTOR: Extraction was successful for %s to %s using password: %s" % (
|
||||||
filePath, outputDestination, password))
|
filePath, outputDestination, password))
|
||||||
pass_success = int(1)
|
success = 1
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
if pass_success == int(0):
|
|
||||||
nzbtomedia.logger.error("EXTRACTOR: Extraction failed for %s. 7zip result was %s" % (filePath, res))
|
|
||||||
except:
|
except:
|
||||||
nzbtomedia.logger.error("EXTRACTOR: Extraction failed for %s. Could not call command %s" % (filePath, cmd))
|
nzbtomedia.logger.error("EXTRACTOR: Extraction failed for %s. Could not call command %s" % (filePath, cmd))
|
||||||
|
os.chdir(pwd)
|
||||||
|
return False
|
||||||
|
|
||||||
os.chdir(pwd) # Go back to our Original Working Directory
|
os.chdir(pwd) # Go back to our Original Working Directory
|
||||||
|
if success:
|
||||||
# sleep to let files finish writing to disk
|
# sleep to let files finish writing to disk
|
||||||
sleep (3)
|
sleep (3)
|
||||||
|
return True
|
||||||
return True
|
else:
|
||||||
|
nzbtomedia.logger.error("EXTRACTOR: Extraction failed for %s. Result was %s" % (filePath, res))
|
||||||
|
return False
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue