add printed return message. Fixes #493 Fixes #495 Fixes#496

This commit is contained in:
clinton-hall 2014-07-17 10:27:55 +09:30
commit de89fb2ce0
7 changed files with 71 additions and 64 deletions

View file

@ -185,7 +185,7 @@ class autoProcessMovie:
status = 1
elif clientAgent == "manual":
logger.warning("No media files found in directory %s to manually process." % (dirName), section)
return 0 # Success (as far as this script is concerned)
return [0, ""] # Success (as far as this script is concerned)
else:
logger.warning("No media files found in directory %s. Processing this as a failed download" % (dirName), section)
status = 1
@ -223,18 +223,18 @@ class autoProcessMovie:
r = requests.get(url, params=params, verify=False)
except requests.ConnectionError:
logger.error("Unable to open URL", section)
return 1 # failure
return [1, "%s: Failed to post-process - Unable to connect to %s" % (section, section) ]
result = r.json()
if not r.status_code in [requests.codes.ok, requests.codes.created, requests.codes.accepted]:
logger.error("Server returned status %s" % (str(r.status_code)), section)
return 1
return [1, "%s: Failed to post-process - Server returned status %s" % (section, str(r.status_code)) ]
elif result['success']:
logger.postprocess("SUCCESS: Finished %s scan for folder %s" % (method, dirName), section)
else:
logger.error("FAILED: %s scan was unable to finish for folder %s. exiting!" % (method, dirName),
section)
return 1 # failure
return [1, "%s: Failed to post-process - Server did not return success" % (section) ]
else:
logger.postprocess("FAILED DOWNLOAD DETECTED FOR %s" % (inputName), section)
@ -246,7 +246,7 @@ class autoProcessMovie:
if not download_id:
logger.error("Could not find a downloaded movie in the database matching %s, exiting!" % inputName,
section)
return 1 # failure
return [1, "%s: Failed to post-process - Failed download not found in %s" % (section, section) ]
logger.postprocess("Setting failed release %s to ignored ..." % (inputName), section)
@ -259,14 +259,17 @@ class autoProcessMovie:
r = requests.get(url, params=params, verify=False)
except requests.ConnectionError:
logger.error("Unable to open URL %s" % (url), section)
return 1 # failure
return [1, "%s: Failed to post-process - Unable to connect to %s" % (section, section) ]
result = r.json()
if result['success']:
if not r.status_code in [requests.codes.ok, requests.codes.created, requests.codes.accepted]:
logger.error("Server returned status %s" % (str(r.status_code)), section)
return [1, "%s: Failed to post-process - Server returned status %s" % (section, str(r.status_code)) ]
elif result['success']:
logger.postprocess("SUCCESS: %s has been set to ignored ..." % (inputName), section)
else:
logger.warning("FAILED: Unable to set %s to ignored!" % (inputName), section)
return 1
return [1, "%s: Failed to post-process - Unable to set %s to ignored" % (section, inputName) ]
logger.postprocess("Trying to snatch the next highest ranked release.", section)
@ -277,18 +280,18 @@ class autoProcessMovie:
r = requests.get(url, params={'media_id': media_id})
except requests.ConnectionError:
logger.error("Unable to open URL %s" % (url), section)
return 1 # failure
return [1, "%s: Failed to post-process - Unable to connect to %s" % (section, section) ]
result = r.json()
if not r.status_code in [requests.codes.ok, requests.codes.created, requests.codes.accepted]:
logger.error("Server returned status %s" % (str(r.status_code)), section)
return 1
return [1, "%s: Failed to post-process - Server returned status %s" % (section, str(r.status_code)) ]
elif result['success']:
logger.postprocess("SUCCESS: Snatched the next highest release ...", section)
return 0
return [0, "%s: Successfully snatched next highest release" % (section) ]
else:
logger.postprocess("SUCCESS: Unable to find a new release to snatch now. CP will keep searching!", section)
return 0 #
return [0, "%s: No new release found now. %s will keep searching" % (section, section) ]
# Added a releease that was not in the wanted list so confirm rename successful by finding this movie media.list.
if not release:
@ -303,24 +306,24 @@ class autoProcessMovie:
try:
if release_id is None and release_status_old is None: # we didn't have a release before, but now we do.
logger.postprocess("SUCCESS: Movie %s has now been added to CouchPotato" % (imdbid), section)
return 0 # success
return [0, "%s: Successfully post-processed %s" % (section, inputName) ]
release_status_new = release[release_id]['status']
if release_status_new != release_status_old:
logger.postprocess("SUCCESS: Release %s has now been marked with a status of [%s]" % (
inputName, str(release_status_new).upper()), section)
return 0 # success
return [0, "%s: Successfully post-processed %s" % (section, inputName) ]
except:
pass
if not os.path.isdir(dirName):
logger.postprocess("SUCCESS: Input Directory [%s] has been processed and removed" % (
dirName), section)
return 0
return [0, "%s: Successfully post-processed %s" % (section, inputName) ]
elif not listMediaFiles(dirName, media=True, audio=False, meta=False, archives=True):
logger.postprocess("SUCCESS: Input Directory [%s] has no remaining media files. This has been fully processed." % (
dirName), section)
return 0
return [0, "%s: Successfully post-processed %s" % (section, inputName) ]
# pause and let CouchPotatoServer catch its breath
time.sleep(10 * wait_for)
@ -329,4 +332,4 @@ class autoProcessMovie:
logger.warning(
"%s does not appear to have changed status after %s minutes, Please check your logs." % (inputName, wait_for),
section)
return 1 # failure
return [1, "%s: Failed to post-process - No change in status" % (section) ]