mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-22 06:13:19 -07:00
Reduce number of return paths.
This commit is contained in:
parent
869e23c236
commit
e953bd9c91
1 changed files with 27 additions and 19 deletions
|
@ -493,20 +493,26 @@ class SickBeard:
|
||||||
response = self.session.get(self.url, auth=(self.sb_init.username, self.sb_init.password), params=self.sb_init.fork_params, stream=True, verify=False, timeout=(30, 1800))
|
response = self.session.get(self.url, auth=(self.sb_init.username, self.sb_init.password), params=self.sb_init.fork_params, stream=True, verify=False, timeout=(30, 1800))
|
||||||
except requests.ConnectionError:
|
except requests.ConnectionError:
|
||||||
logger.error(f'Unable to open URL: {self.url}', self.sb_init.section)
|
logger.error(f'Unable to open URL: {self.url}', self.sb_init.section)
|
||||||
return ProcessResult.failure(
|
result = ProcessResult.failure(
|
||||||
f'{self.sb_init.section}: Failed to post-process - Unable to '
|
f'{self.sb_init.section}: Failed to post-process - Unable to '
|
||||||
f'connect to {self.sb_init.section}'
|
f'connect to {self.sb_init.section}'
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
if response.status_code not in [requests.codes.ok, requests.codes.created, requests.codes.accepted]:
|
successful_statuses = [
|
||||||
|
requests.codes.ok,
|
||||||
|
requests.codes.created,
|
||||||
|
requests.codes.accepted,
|
||||||
|
]
|
||||||
|
if response.status_code not in successful_statuses:
|
||||||
logger.error(f'Server returned status {response.status_code}',
|
logger.error(f'Server returned status {response.status_code}',
|
||||||
self.sb_init.section)
|
self.sb_init.section)
|
||||||
return ProcessResult.failure(
|
result = ProcessResult.failure(
|
||||||
f'{self.sb_init.section}: Failed to post-process - Server '
|
f'{self.sb_init.section}: Failed to post-process - Server '
|
||||||
f'returned status {response.status_code}'
|
f'returned status {response.status_code}'
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
return self.process_response(response)
|
result = self.process_response(response)
|
||||||
|
return result
|
||||||
|
|
||||||
def process_response(self, response: requests.Response) -> ProcessResult:
|
def process_response(self, response: requests.Response) -> ProcessResult:
|
||||||
"""Iterate over the lines returned, and log.
|
"""Iterate over the lines returned, and log.
|
||||||
|
@ -522,18 +528,20 @@ class SickBeard:
|
||||||
# input_name = os.path.split(line)[1]
|
# input_name = os.path.split(line)[1]
|
||||||
# if 'added to the queue' in line:
|
# if 'added to the queue' in line:
|
||||||
# queued = True
|
# queued = True
|
||||||
# For the refactoring i'm only considering vanilla sickbeard, as for the base class.
|
# For the refactoring i'm only considering vanilla sickbeard,
|
||||||
|
# as for the base class.
|
||||||
if 'Processing succeeded' in line or 'Successfully processed' in line:
|
if 'Processing succeeded' in line or 'Successfully processed' in line:
|
||||||
self.success = True
|
self.success = True
|
||||||
|
|
||||||
if self.success:
|
if self.success:
|
||||||
return ProcessResult.success(
|
result = ProcessResult.success(
|
||||||
f'{self.sb_init.section}: Successfully post-processed '
|
f'{self.sb_init.section}: Successfully post-processed '
|
||||||
f'{self.input_name}'
|
f'{self.input_name}'
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
# We did not receive Success confirmation.
|
# We did not receive Success confirmation.
|
||||||
return ProcessResult.failure(
|
result = ProcessResult.failure(
|
||||||
f'{self.sb_init.section}: Failed to post-process - Returned log '
|
f'{self.sb_init.section}: Failed to post-process - Returned '
|
||||||
f'from {self.sb_init.section} was not as expected.'
|
f'log from {self.sb_init.section} was not as expected.'
|
||||||
)
|
)
|
||||||
|
return result
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue