mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-14 10:36:52 -07:00
change the call method and add succesCodes. fixes #185
This commit is contained in:
parent
12cce95d89
commit
80a0a6f28d
3 changed files with 14 additions and 4 deletions
|
@ -10,7 +10,7 @@ import datetime
|
|||
import time
|
||||
import re
|
||||
from sets import Set
|
||||
from subprocess import call
|
||||
from subprocess import call, Popen
|
||||
|
||||
# Custom imports
|
||||
import autoProcess.migratecfg as migratecfg
|
||||
|
@ -286,9 +286,16 @@ def external_script(outputDestination):
|
|||
continue
|
||||
Logger.info("Running script %s on file %s.", command, filePath)
|
||||
try:
|
||||
result = call(command)
|
||||
p = Popen(command)
|
||||
res = p.wait()
|
||||
if res in user_script_successCodes: Linux returns 0 for successful.
|
||||
Logger.info("UserScript %s was successfull", command[0])
|
||||
else:
|
||||
Logger.error("UserScript %s has failed with return code: %s", command[0], res)
|
||||
Logger.info("If the UserScript completed successfully you should add "%s" to the user_script_successCodes", res)
|
||||
result = 1
|
||||
except:
|
||||
Logger.exception("UserScript %s has failed", command)
|
||||
Logger.exception("UserScript %s has failed", command[0])
|
||||
result = 1
|
||||
final_result = final_result + result
|
||||
|
||||
|
@ -374,6 +381,7 @@ if __name__ == "__main__":
|
|||
user_script_mediaExtensions = (config.get("UserScript", "user_script_mediaExtensions")).split(',')
|
||||
user_script = config.get("UserScript", "user_script_path")
|
||||
user_script_param = (config.get("UserScript", "user_script_param")).split(',')
|
||||
user_script_successCodes = (config.get("UserScript", "user_script_successCodes")).split(',')
|
||||
user_script_clean = int(config.get("UserScript", "user_script_clean"))
|
||||
user_delay = int(config.get("UserScript", "delay"))
|
||||
|
||||
|
|
|
@ -139,6 +139,8 @@ user_script_path = /media/test/script/script.sh
|
|||
#for example FP,FN,DN for file path (absolute file name with path), file anme, absolute directory name (with path).
|
||||
#So the result is /media/test/script/script.sh FP FN DN
|
||||
user_script_param = FN
|
||||
#Specify the successcodes returned by the user script as a comma separated list. Linux default is 0
|
||||
user_script_successCodes = 0
|
||||
#Clean after? Note that delay function is used to prevent possible mistake :) Delay is intended as seconds
|
||||
user_script_clean = 1
|
||||
delay = 120
|
||||
|
|
|
@ -119,7 +119,7 @@ def extract(filePath, outputDestination):
|
|||
cmd.append(filePath) # add filePath to final cmd arg.
|
||||
p = Popen(cmd) # should extract files fine.
|
||||
res = p.wait()
|
||||
if res >= 0: # for windows chp returns process id if successful or -1*Error code. Linus returns 0 for successful.
|
||||
if res >= 0: # for windows chp returns process id if successful or -1*Error code. Linux returns 0 for successful.
|
||||
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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue