PEP8: Fix formatting

* Remove redundant backslash between brackets
* Fix multiple statements on one line
* Fix missing/excess whitespace
* Fix comments not starting with a single `#` and a space
* Convert tabs to spaces
This commit is contained in:
Labrys 2016-05-31 11:59:25 -04:00
parent 0a1fe84306
commit 38ed3350ac
5 changed files with 97 additions and 95 deletions

View file

@ -39,13 +39,13 @@ class autoProcessGames(object):
url = "%s%s:%s%s/api" % (protocol, host, port, web_root)
if not server_responding(url):
logger.error("Server did not respond. Exiting", section)
return [1, "%s: Failed to post-process - %s did not respond." % (section, section) ]
return [1, "%s: Failed to post-process - %s did not respond." % (section, section)]
inputName, dirName = convert_to_ascii(inputName, dirName)
fields = inputName.split("-")
gamezID = fields[0].replace("[","").replace("]","").replace(" ","")
gamezID = fields[0].replace("[", "").replace("]", "").replace(" ", "")
downloadStatus = 'Wanted'
if status == 0:
@ -57,33 +57,33 @@ class autoProcessGames(object):
params['db_id'] = gamezID
params['status'] = downloadStatus
logger.debug("Opening URL: %s" % (url),section)
logger.debug("Opening URL: %s" % (url), section)
try:
r = requests.get(url, params=params, verify=False, timeout=(30, 300))
except requests.ConnectionError:
logger.error("Unable to open URL")
return [1, "%s: Failed to post-process - Unable to connect to %s" % (section, section) ]
return [1, "%s: Failed to post-process - Unable to connect to %s" % (section, section)]
result = r.json()
logger.postprocess("%s" % (result),section)
logger.postprocess("%s" % (result), section)
if library:
logger.postprocess("moving files to library: %s" % (library),section)
logger.postprocess("moving files to library: %s" % (library), section)
try:
shutil.move(dirName, os.path.join(library, inputName))
except:
logger.error("Unable to move %s to %s" % (dirName, os.path.join(library, inputName)), section)
return [1, "%s: Failed to post-process - Unable to move files" % (section) ]
return [1, "%s: Failed to post-process - Unable to move files" % (section)]
else:
logger.error("No library specified to move files to. Please edit your configuration.", section)
return [1, "%s: Failed to post-process - No library defined in %s" % (section, section) ]
return [1, "%s: Failed to post-process - No library defined in %s" % (section, section)]
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)) ]
return [1, "%s: Failed to post-process - Server returned status %s" % (section, str(r.status_code))]
elif result['success']:
logger.postprocess("SUCCESS: Status for %s has been set to %s in Gamez" % (gamezID, downloadStatus),section)
return [0, "%s: Successfully post-processed %s" % (section, inputName) ]
logger.postprocess("SUCCESS: Status for %s has been set to %s in Gamez" % (gamezID, downloadStatus), section)
return [0, "%s: Successfully post-processed %s" % (section, inputName)]
else:
logger.error("FAILED: Status for %s has NOT been updated in Gamez" % (gamezID),section)
return [1, "%s: Failed to post-process - Returned log from %s was not as expected." % (section, section) ]
logger.error("FAILED: Status for %s has NOT been updated in Gamez" % (gamezID), section)
return [1, "%s: Failed to post-process - Returned log from %s was not as expected." % (section, section)]