Changed the way requests processes the response back from the autoProcessor

This commit is contained in:
echel0n 2014-04-03 21:51:09 -07:00
commit d93eb866d7
4 changed files with 20 additions and 13 deletions

View file

@ -60,13 +60,13 @@ class autoProcessComics:
Logger.debug("Opening URL: %s", url) Logger.debug("Opening URL: %s", url)
try: try:
r = requests.get(url, auth=(username, password)) r = requests.get(url, auth=(username, password), stream=True)
except requests.ConnectionError: except requests.ConnectionError:
Logger.exception("Unable to open URL") Logger.exception("Unable to open URL")
return 1 # failure return 1 # failure
if r.ok: for line in r.iter_lines():
Logger.info("%s", r.text) if line: Logger.info("%s", line)
time.sleep(60) #wait 1 minute for now... need to see just what gets logged and how long it takes to process time.sleep(60) #wait 1 minute for now... need to see just what gets logged and how long it takes to process
return 0 # Success return 0 # Success

View file

@ -57,13 +57,17 @@ class autoProcessGames:
Logger.debug("Opening URL: %s", url) Logger.debug("Opening URL: %s", url)
try: try:
r = requests.get(url) r = requests.get(url, stream=True)
except requests.ConnectionError: except requests.ConnectionError:
Logger.exception("Unable to open URL") Logger.exception("Unable to open URL")
return 1 # failure return 1 # failure
result = json.load(r.text) result = {}
Logger.info("Gamez returned %s", result) for line in r.iter_lines():
if line:
Logger.info("%s", line)
result.update(json.load(line))
if result['success']: if result['success']:
Logger.info("Status for %s has been set to %s in Gamez", gamezID, downloadStatus) Logger.info("Status for %s has been set to %s in Gamez", gamezID, downloadStatus)
return 0 # Success return 0 # Success

View file

@ -69,7 +69,7 @@ class autoProcessMovie:
release2 = [] release2 = []
moviestatus2 = [] moviestatus2 = []
try: try:
result = json.load(r.text) result = r.json()
movieid2 = [item["_id"] for item in result["movies"]] movieid2 = [item["_id"] for item in result["movies"]]
for item in result["movies"]: for item in result["movies"]:
if "identifier" in item: if "identifier" in item:
@ -143,7 +143,7 @@ class autoProcessMovie:
return None, None return None, None
try: try:
result = json.load(r.text) result = r.json()
movie_status = str(result["media"]["status"]) movie_status = str(result["media"]["status"])
Logger.debug("This movie is marked as status %s in CouchPotatoServer", movie_status) Logger.debug("This movie is marked as status %s in CouchPotatoServer", movie_status)
except: except:
@ -260,7 +260,7 @@ class autoProcessMovie:
Logger.exception("Unable to open URL") Logger.exception("Unable to open URL")
return 1 # failure return 1 # failure
result = json.load(r.text) result = r.json()
Logger.info("CouchPotatoServer returned %s", result) Logger.info("CouchPotatoServer returned %s", result)
if result['success']: if result['success']:
Logger.info("%s scan started on CouchPotatoServer for %s", method, nzbName) Logger.info("%s scan started on CouchPotatoServer for %s", method, nzbName)
@ -283,12 +283,13 @@ class autoProcessMovie:
Logger.debug("Opening URL: %s", url) Logger.debug("Opening URL: %s", url)
try: try:
r = requests.get(url) r = requests.get(url, stream=True)
except requests.ConnectionError: except requests.ConnectionError:
Logger.exception("Unable to open URL") Logger.exception("Unable to open URL")
return 1 # failure return 1 # failure
Logger.info("%s", r.text) for line in r.iter_lines():
if line: Logger.info("%s", line)
Logger.info("Movie %s set to try the next best release on CouchPotatoServer", movie_id) Logger.info("Movie %s set to try the next best release on CouchPotatoServer", movie_id)
if delete_failed and not dirName in ['sys.argv[0]','/','']: if delete_failed and not dirName in ['sys.argv[0]','/','']:
Logger.info("Deleting failed files and folder %s", dirName) Logger.info("Deleting failed files and folder %s", dirName)

View file

@ -177,12 +177,14 @@ class autoProcessTV:
Logger.debug("Opening URL: %s", url) Logger.debug("Opening URL: %s", url)
try: try:
r = requests.get(url, auth=(username, password)) r = requests.get(url, auth=(username, password), stream=True)
except requests.ConnectionError: except requests.ConnectionError:
Logger.exception("Unable to open URL") Logger.exception("Unable to open URL")
return 1 # failure return 1 # failure
Logger.info("%s", r.text) for line in r.iter_lines():
if line: Logger.info("%s", line)
if status != 0 and delete_failed and not dirName in ['sys.argv[0]','/','']: if status != 0 and delete_failed and not dirName in ['sys.argv[0]','/','']:
delete(dirName) delete(dirName)
return 0 # Success return 0 # Success