From 08104ed18de407a1e2a9a57cc77c47dc1ed8270d Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sun, 4 Dec 2022 00:17:50 -0500 Subject: [PATCH] Standardize auto-processors --- core/auto_process/books.py | 28 ++++++------- core/auto_process/comics.py | 28 ++++++------- core/auto_process/games.py | 39 +++++++++--------- core/auto_process/movies.py | 70 ++++++++++++++------------------ core/auto_process/music.py | 79 +++++++++++++++++------------------- core/auto_process/tv.py | 81 +++++++++++++++++-------------------- 6 files changed, 148 insertions(+), 177 deletions(-) diff --git a/core/auto_process/books.py b/core/auto_process/books.py index 6b3ff8b8..98d328ae 100644 --- a/core/auto_process/books.py +++ b/core/auto_process/books.py @@ -36,9 +36,8 @@ def process( url = core.utils.common.create_url(scheme, host, port, web_root) if not server_responding(url): logger.error('Server did not respond. Exiting', section) - return ProcessResult( - message='{0}: Failed to post-process - {0} did not respond.'.format(section), - status_code=1, + return ProcessResult.failure( + f'{section}: Failed to post-process - {section} did not respond.' ) input_name, dir_name = convert_to_ascii(input_name, dir_name) @@ -54,28 +53,27 @@ def process( r = requests.get(url, params=params, verify=False, timeout=(30, 300)) except requests.ConnectionError: logger.error('Unable to open URL') - return ProcessResult( - message='{0}: Failed to post-process - Unable to connect to {1}'.format(section, section), - status_code=1, + return ProcessResult.failure( + f'{section}: Failed to post-process - Unable to connect to ' + f'{section}' ) logger.postprocess('{0}'.format(r.text), section) if r.status_code not in [requests.codes.ok, requests.codes.created, requests.codes.accepted]: logger.error('Server returned status {0}'.format(r.status_code), section) - return ProcessResult( - message='{0}: Failed to post-process - Server returned status {1}'.format(section, r.status_code), - status_code=1, + return ProcessResult.failure( + f'{section}: Failed to post-process - Server returned status ' + f'{r.status_code}' ) elif r.text == 'OK': logger.postprocess('SUCCESS: ForceProcess for {0} has been started in LazyLibrarian'.format(dir_name), section) - return ProcessResult( - message='{0}: Successfully post-processed {1}'.format(section, input_name), - status_code=0, + return ProcessResult.success( + f'{section}: Successfully post-processed {input_name}' ) else: logger.error('FAILED: ForceProcess of {0} has Failed in LazyLibrarian'.format(dir_name), section) - return ProcessResult( - message='{0}: Failed to post-process - Returned log from {0} was not as expected.'.format(section), - status_code=1, + return ProcessResult.failure( + f'{section}: Failed to post-process - Returned log from {section} ' + f'was not as expected.' ) diff --git a/core/auto_process/comics.py b/core/auto_process/comics.py index e7bc0be3..22badb22 100644 --- a/core/auto_process/comics.py +++ b/core/auto_process/comics.py @@ -34,9 +34,8 @@ def process( url = core.utils.common.create_url(scheme, host, port, web_root) if not server_responding(url): logger.error('Server did not respond. Exiting', section) - return ProcessResult( - message='{0}: Failed to post-process - {0} did not respond.'.format(section), - status_code=1, + return ProcessResult.failure( + f'{section}: Failed to post-process - {section} did not respond.' ) input_name, dir_name = convert_to_ascii(input_name, dir_name) @@ -63,15 +62,15 @@ def process( r = requests.post(url, params=params, stream=True, verify=False, timeout=(30, 300)) except requests.ConnectionError: logger.error('Unable to open URL', section) - return ProcessResult( - message='{0}: Failed to post-process - Unable to connect to {0}'.format(section), - status_code=1, + return ProcessResult.failure( + f'{section}: Failed to post-process - Unable to connect to ' + f'{section}' ) if r.status_code not in [requests.codes.ok, requests.codes.created, requests.codes.accepted]: logger.error('Server returned status {0}'.format(r.status_code), section) - return ProcessResult( - message='{0}: Failed to post-process - Server returned status {1}'.format(section, r.status_code), - status_code=1, + return ProcessResult.failure( + f'{section}: Failed to post-process - Server returned status ' + f'{r.status_code}' ) result = r.text @@ -85,13 +84,12 @@ def process( if success: logger.postprocess('SUCCESS: This issue has been processed successfully', section) - return ProcessResult( - message='{0}: Successfully post-processed {1}'.format(section, input_name), - status_code=0, + return ProcessResult.success( + f'{section}: Successfully post-processed {input_name}' ) else: logger.warning('The issue does not appear to have successfully processed. Please check your Logs', section) - return ProcessResult( - message='{0}: Failed to post-process - Returned log from {0} was not as expected.'.format(section), - status_code=1, + return ProcessResult.failure( + f'{section}: Failed to post-process - Returned log from ' + f'{section} was not as expected.' ) diff --git a/core/auto_process/games.py b/core/auto_process/games.py index 8a614761..e3c1cd0b 100644 --- a/core/auto_process/games.py +++ b/core/auto_process/games.py @@ -34,9 +34,8 @@ def process( url = core.utils.common.create_url(scheme, host, port, web_root) if not server_responding(url): logger.error('Server did not respond. Exiting', section) - return ProcessResult( - message='{0}: Failed to post-process - {0} did not respond.'.format(section), - status_code=1, + return ProcessResult.failure( + f'{section}: Failed to post-process - {section} did not respond.' ) input_name, dir_name = convert_to_ascii(input_name, dir_name) @@ -60,9 +59,9 @@ def process( r = requests.get(url, params=params, verify=False, timeout=(30, 300)) except requests.ConnectionError: logger.error('Unable to open URL') - return ProcessResult( - message='{0}: Failed to post-process - Unable to connect to {1}'.format(section, section), - status_code=1, + return ProcessResult.failure( + f'{section}: Failed to post-process - Unable to connect to ' + f'{section}' ) result = r.json() @@ -73,32 +72,30 @@ def process( shutil.move(dir_name, os.path.join(library, input_name)) except Exception: logger.error('Unable to move {0} to {1}'.format(dir_name, os.path.join(library, input_name)), section) - return ProcessResult( - message='{0}: Failed to post-process - Unable to move files'.format(section), - status_code=1, + return ProcessResult.failure( + f'{section}: Failed to post-process - Unable to move files' ) else: logger.error('No library specified to move files to. Please edit your configuration.', section) - return ProcessResult( - message='{0}: Failed to post-process - No library defined in {0}'.format(section), - status_code=1, + return ProcessResult.failure( + f'{section}: Failed to post-process - No library defined in ' + f'{section}' ) if r.status_code not in [requests.codes.ok, requests.codes.created, requests.codes.accepted]: logger.error('Server returned status {0}'.format(r.status_code), section) - return ProcessResult( - message='{0}: Failed to post-process - Server returned status {1}'.format(section, r.status_code), - status_code=1, + return ProcessResult.failure( + f'{section}: Failed to post-process - Server returned status ' + f'{r.status_code}' ) elif result['success']: logger.postprocess('SUCCESS: Status for {0} has been set to {1} in Gamez'.format(gamez_id, download_status), section) - return ProcessResult( - message='{0}: Successfully post-processed {1}'.format(section, input_name), - status_code=0, + return ProcessResult.success( + f'{section}: Successfully post-processed {input_name}' ) else: logger.error('FAILED: Status for {0} has NOT been updated in Gamez'.format(gamez_id), section) - return ProcessResult( - message='{0}: Failed to post-process - Returned log from {0} was not as expected.'.format(section), - status_code=1, + return ProcessResult.failure( + f'{section}: Failed to post-process - Returned log from {section} ' + f'was not as expected.' ) diff --git a/core/auto_process/movies.py b/core/auto_process/movies.py index 422c22b3..6ce8a347 100644 --- a/core/auto_process/movies.py +++ b/core/auto_process/movies.py @@ -88,9 +88,8 @@ def process( release = None else: logger.error('Server did not respond. Exiting', section) - return ProcessResult( - message='{0}: Failed to post-process - {0} did not respond.'.format(section), - status_code=1, + return ProcessResult.failure( + f'{section}: Failed to post-process - {section} did not respond.' ) # pull info from release found if available @@ -368,29 +367,28 @@ def process( r = requests.get(url, params={'media_id': media_id}, verify=False, timeout=(30, 600)) except requests.ConnectionError: logger.error('Unable to open URL {0}'.format(url), section) - return ProcessResult( - message='{0}: Failed to post-process - Unable to connect to {0}'.format(section), - status_code=1, + return ProcessResult.failure( + f'{section}: Failed to post-process - Unable to connect to ' + f'{section}' ) result = r.json() if r.status_code not in [requests.codes.ok, requests.codes.created, requests.codes.accepted]: logger.error('Server returned status {0}'.format(r.status_code), section) - return ProcessResult( - message='{0}: Failed to post-process - Server returned status {1}'.format(section, r.status_code), - status_code=1, + return ProcessResult.failure( + f'{section}: Failed to post-process - Server returned status ' + f'{r.status_code}' ) elif result['success']: logger.postprocess('SUCCESS: Snatched the next highest release ...', section) - return ProcessResult( - message='{0}: Successfully snatched next highest release'.format(section), - status_code=0, + return ProcessResult.success( + f'{section}: Successfully snatched next highest release' ) else: logger.postprocess('SUCCESS: Unable to find a new release to snatch now. CP will keep searching!', section) - return ProcessResult( - status_code=0, - message='{0}: No new release found now. {0} will keep searching'.format(section), + return ProcessResult.success( + f'{section}: No new release found now. ' + f'{section} will keep searching' ) # Added a release that was not in the wanted list so confirm rename successful by finding this movie media.list. @@ -398,9 +396,9 @@ def process( download_id = None # we don't want to filter new releases based on this. if no_status_check: - return ProcessResult( - status_code=0, - message='{0}: Successfully processed but no change in status confirmed'.format(section), + return ProcessResult.success( + f'{section}: Successfully processed but no change in status ' + f'confirmed' ) # we will now check to see if CPS has finished renaming before returning to TorrentToMedia and unpausing. @@ -420,17 +418,15 @@ def process( title = release[release_id]['title'] logger.postprocess('SUCCESS: Movie {0} has now been added to CouchPotato with release status of [{1}]'.format( title, str(release_status_new).upper()), section) - return ProcessResult( - message='{0}: Successfully post-processed {1}'.format(section, input_name), - status_code=0, + return ProcessResult.success( + f'{section}: Successfully post-processed {input_name}' ) if release_status_new != release_status_old: logger.postprocess('SUCCESS: Release {0} has now been marked with a status of [{1}]'.format( release_id, str(release_status_new).upper()), section) - return ProcessResult( - message='{0}: Successfully post-processed {1}'.format(section, input_name), - status_code=0, + return ProcessResult.success( + f'{section}: Successfully post-processed {input_name}' ) except Exception: pass @@ -441,9 +437,8 @@ def process( logger.debug('The Scan command return status: {0}'.format(command_status), section) if command_status in ['completed']: logger.debug('The Scan command has completed successfully. Renaming was successful.', section) - return ProcessResult( - message='{0}: Successfully post-processed {1}'.format(section, input_name), - status_code=0, + return ProcessResult.success( + f'{section}: Successfully post-processed {input_name}' ) elif command_status in ['failed']: logger.debug('The Scan command has failed. Renaming was not successful.', section) @@ -455,17 +450,15 @@ def process( if not os.path.isdir(dir_name): logger.postprocess('SUCCESS: Input Directory [{0}] has been processed and removed'.format( dir_name), section) - return ProcessResult( - status_code=0, - message='{0}: Successfully post-processed {1}'.format(section, input_name), + return ProcessResult.success( + f'{section}: Successfully post-processed {input_name}' ) elif not list_media_files(dir_name, media=True, audio=False, meta=False, archives=True): logger.postprocess('SUCCESS: Input Directory [{0}] has no remaining media files. This has been fully processed.'.format( dir_name), section) - return ProcessResult( - message='{0}: Successfully post-processed {1}'.format(section, input_name), - status_code=0, + return ProcessResult.success( + f'{section}: Successfully post-processed {input_name}' ) # pause and let CouchPotatoServer/Radarr catch its breath @@ -474,18 +467,17 @@ def process( # The status hasn't changed. we have waited wait_for minutes which is more than enough. uTorrent can resume seeding now. if section == 'Radarr' and completed_download_handling(url2, headers, section=section): logger.debug('The Scan command did not return status completed, but complete Download Handling is enabled. Passing back to {0}.'.format(section), section) - return ProcessResult( - message='{0}: Complete DownLoad Handling is enabled. Passing back to {0}'.format(section), - status_code=status, + return ProcessResult.success( + f'{section}: Complete DownLoad Handling is enabled. Passing back ' + f'to {section}' ) logger.warning( '{0} does not appear to have changed status after {1} minutes, Please check your logs.'.format(input_name, wait_for), section, ) - return ProcessResult( - status_code=1, - message='{0}: Failed to post-process - No change in status'.format(section), + return ProcessResult.failure( + f'{section}: Failed to post-process - No change in status' ) diff --git a/core/auto_process/music.py b/core/auto_process/music.py index 4f39757b..29adda5d 100644 --- a/core/auto_process/music.py +++ b/core/auto_process/music.py @@ -44,9 +44,8 @@ def process( url = core.utils.common.create_url(scheme, host, port, route) if not server_responding(url): logger.error('Server did not respond. Exiting', section) - return ProcessResult( - message='{0}: Failed to post-process - {0} did not respond.'.format(section), - status_code=1, + return ProcessResult.failure( + f'{section}: Failed to post-process - {section} did not respond.' ) if not os.path.isdir(dir_name) and os.path.isfile(dir_name): # If the input directory is a file, assume single file download and split dir/name. @@ -95,9 +94,8 @@ def process( # The status hasn't changed. uTorrent can resume seeding now. logger.warning('The music album does not appear to have changed status after {0} minutes. Please check your Logs'.format(wait_for), section) - return ProcessResult( - message='{0}: Failed to post-process - No change in wanted status'.format(section), - status_code=1, + return ProcessResult.failure( + f'{section}: Failed to post-process - No change in wanted status' ) elif status == 0 and section == 'Lidarr': @@ -116,9 +114,9 @@ def process( r = requests.post(url, data=data, headers=headers, stream=True, verify=False, timeout=(30, 1800)) except requests.ConnectionError: logger.error('Unable to open URL: {0}'.format(url), section) - return ProcessResult( - message='{0}: Failed to post-process - Unable to connect to {0}'.format(section), - status_code=1, + return ProcessResult.failure( + f'{section}: Failed to post-process - Unable to connect to ' + f'{section}' ) try: @@ -127,9 +125,8 @@ def process( logger.debug('Scan started with id: {0}'.format(scan_id), section) except Exception as e: logger.warning('No scan id was returned due to: {0}'.format(e), section) - return ProcessResult( - message='{0}: Failed to post-process - Unable to start scan'.format(section), - status_code=1, + return ProcessResult.failure( + f'{section}: Failed to post-process - Unable to start scan' ) n = 0 @@ -145,44 +142,43 @@ def process( logger.debug('The Scan command return status: {0}'.format(command_status), section) if not os.path.exists(dir_name): logger.debug('The directory {0} has been removed. Renaming was successful.'.format(dir_name), section) - return ProcessResult( - message='{0}: Successfully post-processed {1}'.format(section, input_name), - status_code=0, + return ProcessResult.success( + f'{section}: Successfully post-processed {input_name}' ) elif command_status and command_status in ['completed']: logger.debug('The Scan command has completed successfully. Renaming was successful.', section) - return ProcessResult( - message='{0}: Successfully post-processed {1}'.format(section, input_name), - status_code=0, + return ProcessResult.success( + f'{section}: Successfully post-processed {input_name}' ) elif command_status and command_status in ['failed']: logger.debug('The Scan command has failed. Renaming was not successful.', section) - # return ProcessResult( - # message='{0}: Failed to post-process {1}'.format(section, input_name), - # status_code=1, + # return ProcessResult.failure( + # f'{section}: Failed to post-process {input_name}' # ) else: logger.debug('The Scan command did not return status completed. Passing back to {0} to attempt complete download handling.'.format(section), section) return ProcessResult( - message='{0}: Passing back to {0} to attempt Complete Download Handling'.format(section), + message=f'{section}: Passing back to {section} to attempt ' + f'Complete Download Handling', status_code=status, ) else: if section == 'Lidarr': logger.postprocess('FAILED: The download failed. Sending failed download to {0} for CDH processing'.format(section), section) - return ProcessResult( - message='{0}: Download Failed. Sending back to {0}'.format(section), - status_code=1, # Return as failed to flag this in the downloader. + # Return as failed to flag this in the downloader. + return ProcessResult.failure( + f'{section}: Download Failed. Sending back to {section}' ) else: logger.warning('FAILED DOWNLOAD DETECTED', section) if delete_failed and os.path.isdir(dir_name) and not os.path.dirname(dir_name) == dir_name: logger.postprocess('Deleting failed files and folder {0}'.format(dir_name), section) remove_dir(dir_name) - return ProcessResult( - message='{0}: Failed to post-process. {0} does not support failed downloads'.format(section), - status_code=1, # Return as failed to flag this in the downloader. + # Return as failed to flag this in the downloader. + return ProcessResult.failure( + f'{section}: Failed to post-process. {section} does not ' + f'support failed downloads' ) @@ -224,26 +220,25 @@ def force_process(params, url, apikey, input_name, dir_name, section, wait_for): r = requests.get(url, params=params, verify=False, timeout=(30, 300)) except requests.ConnectionError: logger.error('Unable to open URL {0}'.format(url), section) - return ProcessResult( - message='{0}: Failed to post-process - Unable to connect to {0}'.format(section), - status_code=1, + return ProcessResult.failure( + f'{section}: Failed to post-process - Unable to connect to ' + f'{section}' ) logger.debug('Result: {0}'.format(r.text), section) if r.status_code not in [requests.codes.ok, requests.codes.created, requests.codes.accepted]: logger.error('Server returned status {0}'.format(r.status_code), section) - return ProcessResult( - message='{0}: Failed to post-process - Server returned status {1}'.format(section, r.status_code), - status_code=1, + return ProcessResult.failure( + f'{section}: Failed to post-process - Server returned status {r.status_code}' ) elif r.text == 'OK': logger.postprocess('SUCCESS: Post-Processing started for {0} in folder {1} ...'.format(input_name, dir_name), section) else: logger.error('FAILED: Post-Processing has NOT started for {0} in folder {1}. exiting!'.format(input_name, dir_name), section) - return ProcessResult( - message='{0}: Failed to post-process - Returned log from {0} was not as expected.'.format(section), - status_code=1, + return ProcessResult.failure( + f'{section}: Failed to post-process - Returned log from {section} ' + f'was not as expected.' ) # we will now wait for this album to be processed before returning to TorrentToMedia and unpausing. @@ -252,15 +247,13 @@ def force_process(params, url, apikey, input_name, dir_name, section, wait_for): current_status = get_status(url, apikey, dir_name) 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 [{0}]'.format(current_status), section) - return ProcessResult( - message='{0}: Successfully post-processed {1}'.format(section, input_name), - status_code=0, + return ProcessResult.success( + f'{section}: Successfully post-processed {input_name}' ) if not os.path.isdir(dir_name): logger.postprocess('SUCCESS: The input directory {0} has been removed Processing must have finished.'.format(dir_name), section) - return ProcessResult( - message='{0}: Successfully post-processed {1}'.format(section, input_name), - status_code=0, + return ProcessResult.success( + f'{section}: Successfully post-processed {input_name}' ) time.sleep(10 * wait_for) # The status hasn't changed. diff --git a/core/auto_process/tv.py b/core/auto_process/tv.py index fa2e7254..b3bc76ca 100644 --- a/core/auto_process/tv.py +++ b/core/auto_process/tv.py @@ -71,9 +71,8 @@ def process( fork, fork_params = 'None', {} else: logger.error('Server did not respond. Exiting', section) - return ProcessResult( - status_code=1, - message='{0}: Failed to post-process - {0} did not respond.'.format(section), + return ProcessResult.failure( + f'{section}: Failed to post-process - {section} did not respond.' ) delete_failed = int(cfg.get('delete_failed', 0)) @@ -161,10 +160,8 @@ def process( failure_link += '&corrupt=true' elif client_agent == 'manual': logger.warning('No media files found in directory {0} to manually process.'.format(dir_name), section) - return ProcessResult( - message='', - status_code=0, # Success (as far as this script is concerned) - ) + # Success (as far as this script is concerned) + return ProcessResult.success() elif nzb_extraction_by == 'Destination': logger.info('Check for media files ignored because nzbExtractionBy is set to Destination.') if int(failed) == 0: @@ -195,9 +192,8 @@ def process( core.rchmod(dir_name, chmod_directory) else: logger.error('FAILED: Transcoding failed for files in {0}'.format(dir_name), section) - return ProcessResult( - message='{0}: Failed to post-process - Transcoding failed'.format(section), - status_code=1, + return ProcessResult.failure( + f'{section}: Failed to post-process - Transcoding failed' ) # Part of the refactor @@ -272,9 +268,8 @@ def process( if status == 0: if section == 'NzbDrone' and not apikey: logger.info('No Sonarr apikey entered. Processing completed.') - return ProcessResult( - message='{0}: Successfully post-processed {1}'.format(section, input_name), - status_code=0, + return ProcessResult.success( + f'{section}: Successfully post-processed {input_name}' ) logger.postprocess('SUCCESS: The download succeeded, sending a post-process request', section) else: @@ -285,18 +280,19 @@ def process( logger.postprocess('FAILED: The download failed. Sending \'failed\' process request to {0} branch'.format(fork), section) elif section == 'NzbDrone': logger.postprocess('FAILED: The download failed. Sending failed download to {0} for CDH processing'.format(fork), section) - return ProcessResult( - message='{0}: Download Failed. Sending back to {0}'.format(section), - status_code=1, # Return as failed to flag this in the downloader. + # Return as failed to flag this in the downloader. + return ProcessResult.failure( + f'{section}: Download Failed. Sending back to {section}' ) else: logger.postprocess('FAILED: The download failed. {0} branch does not handle failed downloads. Nothing to process'.format(fork), section) if delete_failed and os.path.isdir(dir_name) and not os.path.dirname(dir_name) == dir_name: logger.postprocess('Deleting failed files and folder {0}'.format(dir_name), section) remove_dir(dir_name) - return ProcessResult( - message='{0}: Failed to post-process. {0} does not support failed downloads'.format(section), - status_code=1, # Return as failed to flag this in the downloader. + # Return as failed to flag this in the downloader. + return ProcessResult.failure( + f'{section}: Failed to post-process. {section} does not ' + f'support failed downloads' ) route = '' @@ -376,16 +372,16 @@ def process( r = requests.post(url, data=data, headers=headers, stream=True, verify=False, timeout=(30, 1800)) except requests.ConnectionError: logger.error('Unable to open URL: {0}'.format(url), section) - return ProcessResult( - message='{0}: Failed to post-process - Unable to connect to {0}'.format(section), - status_code=1, + return ProcessResult.failure( + f'{section}: Failed to post-process - Unable to connect to ' + f'{section}' ) if r.status_code not in [requests.codes.ok, requests.codes.created, requests.codes.accepted]: logger.error('Server returned status {0}'.format(r.status_code), section) - return ProcessResult( - message='{0}: Failed to post-process - Server returned status {1}'.format(section, r.status_code), - status_code=1, + return ProcessResult.failure( + f'{section}: Failed to post-process - Server returned status ' + f'{r.status_code}' ) success = False @@ -431,9 +427,8 @@ def process( remove_dir(dir_name) if success: - return ProcessResult( - message='{0}: Successfully post-processed {1}'.format(section, input_name), - status_code=0, + return ProcessResult.success( + f'{section}: Successfully post-processed {input_name}' ) elif section == 'NzbDrone' and started: n = 0 @@ -449,21 +444,18 @@ def process( logger.debug('The Scan command return status: {0}'.format(command_status), section) if not os.path.exists(dir_name): logger.debug('The directory {0} has been removed. Renaming was successful.'.format(dir_name), section) - return ProcessResult( - message='{0}: Successfully post-processed {1}'.format(section, input_name), - status_code=0, + return ProcessResult.success( + f'{section}: Successfully post-processed {input_name}' ) elif command_status and command_status in ['completed']: logger.debug('The Scan command has completed successfully. Renaming was successful.', section) - return ProcessResult( - message='{0}: Successfully post-processed {1}'.format(section, input_name), - status_code=0, + return ProcessResult.success( + f'{section}: Successfully post-processed {input_name}' ) elif command_status and command_status in ['failed']: logger.debug('The Scan command has failed. Renaming was not successful.', section) - # return ProcessResult( - # message='{0}: Failed to post-process {1}'.format(section, input_name), - # status_code=1, + # return ProcessResult.failure( + # f'{section}: Failed to post-process {input_name}' # ) url2 = core.utils.common.create_url(scheme, host, port, route) @@ -471,17 +463,18 @@ def process( logger.debug('The Scan command did not return status completed, but complete Download Handling is enabled. Passing back to {0}.'.format(section), section) return ProcessResult( - message='{0}: Complete DownLoad Handling is enabled. Passing back to {0}'.format(section), + message=f'{section}: Complete DownLoad Handling is enabled. ' + f'Passing back to {section}', status_code=status, ) else: logger.warning('The Scan command did not return a valid status. Renaming was not successful.', section) - return ProcessResult( - message='{0}: Failed to post-process {1}'.format(section, input_name), - status_code=1, + return ProcessResult.failure( + f'{section}: Failed to post-process {input_name}' ) else: - return ProcessResult( - message='{0}: Failed to post-process - Returned log from {0} was not as expected.'.format(section), - status_code=1, # We did not receive Success confirmation. + # We did not receive Success confirmation. + return ProcessResult.failure( + f'{section}: Failed to post-process - Returned log from {section} ' + f'was not as expected.' )