Remove unused imports, unused variables, and redundant parentheses

This commit is contained in:
labrys 2016-05-31 04:26:09 -04:00 committed by Labrys
parent b7c7ec000b
commit d15fa76fc9
5 changed files with 10 additions and 18 deletions

View file

@ -1,13 +1,10 @@
# coding=utf-8 # coding=utf-8
import os import os
import time
import core import core
import requests import requests
import time
from core.nzbToMediaUtil import convert_to_ascii, remoteDir, server_responding from core.nzbToMediaUtil import convert_to_ascii, remoteDir, server_responding
from core.nzbToMediaSceneExceptions import process_all_exceptions
from core import logger from core import logger
requests.packages.urllib3.disable_warnings() requests.packages.urllib3.disable_warnings()

View file

@ -6,7 +6,6 @@ import requests
import shutil import shutil
from core.nzbToMediaUtil import convert_to_ascii, server_responding from core.nzbToMediaUtil import convert_to_ascii, server_responding
from core.nzbToMediaSceneExceptions import process_all_exceptions
from core import logger from core import logger
requests.packages.urllib3.disable_warnings() requests.packages.urllib3.disable_warnings()

View file

@ -325,7 +325,7 @@ class autoProcessMovie:
# we will now check to see if CPS has finished renaming before returning to TorrentToMedia and unpausing. # we will now check to see if CPS has finished renaming before returning to TorrentToMedia and unpausing.
timeout = time.time() + 60 * wait_for timeout = time.time() + 60 * wait_for
while (time.time() < timeout): # only wait 2 (default) minutes, then return. while time.time() < timeout: # only wait 2 (default) minutes, then return.
logger.postprocess("Checking for status change, please stand by ...", section) logger.postprocess("Checking for status change, please stand by ...", section)
release = self.get_release(baseURL, imdbid, download_id, release_id) release = self.get_release(baseURL, imdbid, download_id, release_id)
if release: if release:

View file

@ -132,7 +132,7 @@ class autoProcessMusic:
# we will now wait for this album to be processed before returning to TorrentToMedia and unpausing. # we will now wait for this album to be processed before returning to TorrentToMedia and unpausing.
timeout = time.time() + 60 * wait_for timeout = time.time() + 60 * wait_for
while (time.time() < timeout): while time.time() < timeout:
current_status = self.get_status(url, apikey, dirName) current_status = self.get_status(url, apikey, dirName)
if current_status is not None and current_status != release_status: # Something has changed. CPS must have processed this movie. if current_status is not None and current_status != release_status: # Something has changed. CPS must have processed this movie.
logger.postprocess("SUCCESS: This release is now marked as status [%s]" % (current_status),section) logger.postprocess("SUCCESS: This release is now marked as status [%s]" % (current_status),section)

View file

@ -18,7 +18,6 @@ requests.packages.urllib3.disable_warnings()
class autoProcessTV: class autoProcessTV:
def command_complete(self, url, params, headers, section): def command_complete(self, url, params, headers, section):
r = None
try: try:
r = requests.get(url, params=params, headers=headers, stream=True, verify=False, timeout=(30, 60)) r = requests.get(url, params=params, headers=headers, stream=True, verify=False, timeout=(30, 60))
except requests.ConnectionError: except requests.ConnectionError:
@ -36,7 +35,6 @@ class autoProcessTV:
return None return None
def CDH(self, url2, headers): def CDH(self, url2, headers):
r = None
try: try:
r = requests.get(url2, params={}, headers=headers, stream=True, verify=False, timeout=(30, 60)) r = requests.get(url2, params={}, headers=headers, stream=True, verify=False, timeout=(30, 60))
except requests.ConnectionError: except requests.ConnectionError:
@ -150,8 +148,8 @@ class autoProcessTV:
inputName, dirName = convert_to_ascii(inputName, dirName) inputName, dirName = convert_to_ascii(inputName, dirName)
if listMediaFiles(dirName, media=True, audio=False, meta=False, archives=False): # Check that a video exists. if not, assume failed. if listMediaFiles(dirName, media=True, audio=False, meta=False, archives=False): # Check that a video exists. if not, assume failed.
flatten(dirName) flatten(dirName)
# Check video files for corruption # Check video files for corruption
status = int(failed) status = int(failed)
good_files = 0 good_files = 0
@ -161,7 +159,7 @@ class autoProcessTV:
if transcoder.isVideoGood(video, status): if transcoder.isVideoGood(video, status):
good_files += 1 good_files += 1
import_subs(video) import_subs(video)
if num_files > 0: if num_files > 0:
if good_files == num_files and not status == 0: if good_files == num_files and not status == 0:
logger.info('Found Valid Videos. Setting status Success') logger.info('Found Valid Videos. Setting status Success')
status = 0 status = 0
@ -263,7 +261,7 @@ class autoProcessTV:
url = "%s%s:%s%s/api/command" % (protocol, host, port, web_root) url = "%s%s:%s%s/api/command" % (protocol, host, port, web_root)
url2 = "%s%s:%s%s/api/config/downloadClient" % (protocol, host, port, web_root) url2 = "%s%s:%s%s/api/config/downloadClient" % (protocol, host, port, web_root)
headers = {"X-Api-Key": apikey} headers = {"X-Api-Key": apikey}
params = {'sortKey': 'series.title', 'page': 1, 'pageSize': 1, 'sortDir': 'asc'} # params = {'sortKey': 'series.title', 'page': 1, 'pageSize': 1, 'sortDir': 'asc'}
if remote_path: if remote_path:
logger.debug("remote_path: %s" % (remoteDir(dirName)),section) logger.debug("remote_path: %s" % (remoteDir(dirName)),section)
data = {"name": "DownloadedEpisodesScan", "path": remoteDir(dirName), "downloadClientId": download_id} data = {"name": "DownloadedEpisodesScan", "path": remoteDir(dirName), "downloadClientId": download_id}
@ -273,11 +271,10 @@ class autoProcessTV:
if not download_id: if not download_id:
data.pop("downloadClientId") data.pop("downloadClientId")
data = json.dumps(data) data = json.dumps(data)
try: try:
if section == "SickBeard": if section == "SickBeard":
logger.debug("Opening URL: %s with params: %s" % (url, str(fork_params)), section) logger.debug("Opening URL: %s with params: %s" % (url, str(fork_params)), section)
r = None
s = requests.Session() s = requests.Session()
login = "%s%s:%s%s/login" % (protocol,host,port,web_root) login = "%s%s:%s%s/login" % (protocol,host,port,web_root)
login_params = {'username': username, 'password': password} login_params = {'username': username, 'password': password}
@ -285,7 +282,6 @@ class autoProcessTV:
r = s.get(url, auth=(username, password), params=fork_params, stream=True, verify=False, timeout=(30, 1800)) r = s.get(url, auth=(username, password), params=fork_params, stream=True, verify=False, timeout=(30, 1800))
elif section == "NzbDrone": elif section == "NzbDrone":
logger.debug("Opening URL: %s with data: %s" % (url, str(data)), section) logger.debug("Opening URL: %s with data: %s" % (url, str(data)), section)
r = None
r = requests.post(url, data=data, headers=headers, stream=True, verify=False, timeout=(30, 1800)) r = requests.post(url, data=data, headers=headers, stream=True, verify=False, timeout=(30, 1800))
except requests.ConnectionError: except requests.ConnectionError:
logger.error("Unable to open URL: %s" % (url), section) logger.error("Unable to open URL: %s" % (url), section)
@ -299,7 +295,7 @@ class autoProcessTV:
Started = False Started = False
if section == "SickBeard": if section == "SickBeard":
for line in r.iter_lines(): for line in r.iter_lines():
if line: if line:
logger.postprocess("%s" % (line), section) logger.postprocess("%s" % (line), section)
if "Moving file from" in line: if "Moving file from" in line:
inputName = os.path.split(line)[1] inputName = os.path.split(line)[1]
@ -329,7 +325,7 @@ class autoProcessTV:
while n < 6: # set up wait_for minutes to see if command completes.. while n < 6: # set up wait_for minutes to see if command completes..
time.sleep(10 * wait_for) time.sleep(10 * wait_for)
command_status = self.command_complete(url, params, headers, section) command_status = self.command_complete(url, params, headers, section)
if command_status and command_status in ['completed', 'failed']: if command_status and command_status in ['completed', 'failed']:
break break
n += 1 n += 1
if command_status: if command_status:
@ -345,7 +341,7 @@ class autoProcessTV:
#return [1, "%s: Failed to post-process %s" % (section, inputName) ] #return [1, "%s: Failed to post-process %s" % (section, inputName) ]
if self.CDH(url2, headers): if self.CDH(url2, headers):
logger.debug("The Scan command did not return status completed, but complete Download Handling is enabled. Passing back to %s." % (section), section) logger.debug("The Scan command did not return status completed, but complete Download Handling is enabled. Passing back to %s." % (section), section)
return [status, "%s: Complete DownLoad Handling is enabled. Passing back to %s" % (section, section) ] return [status, "%s: Complete DownLoad Handling is enabled. Passing back to %s" % (section, section) ]
else: else:
logger.warning("The Scan command did not return a valid status. Renaming was not successful.", section) logger.warning("The Scan command did not return a valid status. Renaming was not successful.", section)
return [1, "%s: Failed to post-process %s" % (section, inputName) ] return [1, "%s: Failed to post-process %s" % (section, inputName) ]