Post processing status code troubles with my PP script
Posted: May 7th, 2013, 9:07 am
I use my own post processing script to process all of my Sickbeard downloads. It can be seen below:
I tested a download that returned the following post processing parameters:
As you can see, the post-processing code returned was 0. However, my script followed the 'elif pp_status != 0:' condition and sent the Download failed notification. Is something wrong with my PP script that is causing this to happen? I'm not a Python expert so if anybody could point out any logic faults in my script that would be great. Thanks for your help!
Code: Select all
#!/usr/bin/env python
import httplib
import subprocess
import sys
import os
import shutil
source_path = sys.argv[1]
file_name = sys.argv[3]
category = sys.argv[5]
pp_status = sys.argv[7]
move_dir = "/mnt/user/Downloads/"
if pp_status == 0:
currentDir = os.path.abspath(source_path)
filesInCurDir = os.listdir(currentDir)
for file in filesInCurDir:
curFile = os.path.join(currentDir, file)
if os.path.isfile(curFile):
curFileExtension = curFile[-3:]
if curFileExtension in ['avi', 'mkv', 'mp4'] and not "sample" in curFile:
try:
shutil.move(curFile, move_dir)
except shutil.Error:
print "\nDestination path " + curFile + " already exists"
shutil.rmtree(currentDir)
with open(os.devnull) as devnull:
subprocess.call(['curl', '-s', '-F', 'token=*****', '-F', 'user=*****', '-F', 'title=Download Finished', '-F', 'message=' + file_name, 'https://api.pushover.net/1/messages.json'], stdout=devnull, stderr=devnull)
connection = httplib.HTTPConnection('*****')
body_content = '<action><name>forceLibraryRefresh</name></action>'
headers = { "Content-type": "text/xml" }
connection.request('POST', '/rest/action' , body_content , headers)
result = connection.getresponse()
if result.status == 200:
print "\nUpdated Serviio Library"
else:
print "\nUpdate Failed"
elif pp_status != 0:
with open(os.devnull) as devnull:
subprocess.call(['curl', '-s', '-F', 'token=*****', '-F', 'user=*****', '-F', 'title=Download Failed', '-F', 'message=' + file_name, 'https://api.pushover.net/1/messages.json'], stdout=devnull, stderr=devnull)
Code: Select all
please sanitize before posting