diff --git a/app/commands/file.py b/app/commands/file.py index 58871f25..c3bacfaf 100644 --- a/app/commands/file.py +++ b/app/commands/file.py @@ -4,8 +4,10 @@ import json import os +from sys import exit import click +from click.exceptions import Abort import app.services.output_manager.help_page as file_help import app.services.output_manager.message_handler as message_handler @@ -125,16 +127,26 @@ def file_put(**kwargs): # noqa: C901 zone = get_zone(zone) if zone else AppConfig.Env.green_zone.lower() toc = customized_error_msg(ECustomizedError.TOU_CONTENT).replace(' ', '...') - if zone.lower() == AppConfig.Env.core_zone.lower() and click.confirm(fit_terminal_width(toc), abort=True): - pass + try: + if zone.lower() == AppConfig.Env.core_zone.lower() and click.confirm(fit_terminal_width(toc), abort=True): + pass + except Abort: + message_handler.SrvOutPutHandler.cancel_upload() + exit(1) # check if user input at least one file/folder if len(paths) == 0: SrvErrorHandler.customized_handle(ECustomizedError.INVALID_PATHS, True) # check if the manifest file exists - if os.path.exists(output_path): - click.confirm(customized_error_msg(ECustomizedError.MANIFEST_OF_FOLDER_FILE_EXIST) % (output_path), abort=True) + try: + if os.path.exists(output_path): + click.confirm( + customized_error_msg(ECustomizedError.MANIFEST_OF_FOLDER_FILE_EXIST) % (output_path), abort=True + ) + except Abort: + message_handler.SrvOutPutHandler.cancel_upload() + exit(1) project_path = click.prompt('ProjectCode') if not project_path else project_path project_code, target_folder = identify_target_folder(project_path) diff --git a/app/resources/custom_error.py b/app/resources/custom_error.py index a8eff967..16a1c4f4 100644 --- a/app/resources/custom_error.py +++ b/app/resources/custom_error.py @@ -109,10 +109,10 @@ class Error: 'USER_NOT_FOUND': 'User not found.', 'CONTAINER_REGISTRY_OTHER': 'Encountered an error when interacting with container registry.', 'TOU_CONTENT': ( - 'You are about to transfer data directly to the PILOT Core! ' - 'In accordance with the PILOT Terms of Use, please confirm that you have made your best efforts ' + 'You are about to transfer data directly to the Pilot Core. ' + 'In accordance with the Pilot Terms of Use, please confirm that you have made your best efforts ' 'to pseudonymize or anonymize the data and that you have the legal authority to transfer and make this ' - 'data available for dissemination and use within the PILOT. If you need to process the data to remove ' + 'data available for dissemination and use within Pilot. If you need to process the data to remove ' 'sensitive identifiers, please cancel this transfer and upload the data to the Green Room to perform ' 'these actions.' ), diff --git a/app/services/file_manager/file_upload/file_upload.py b/app/services/file_manager/file_upload/file_upload.py index d663eee0..64c600e4 100644 --- a/app/services/file_manager/file_upload/file_upload.py +++ b/app/services/file_manager/file_upload/file_upload.py @@ -93,8 +93,14 @@ def assemble_path( # find the longest existing folder as parent folder # if user input a path that need to create some folders if not res.get('result'): + try: + click.confirm(customized_error_msg(ECustomizedError.CREATE_FOLDER_IF_NOT_EXIST), abort=True) + except Abort: + mhandler.SrvOutPutHandler.cancel_upload() + exit(1) + + # stop scaning and use the current folder as parent folder current_folder_node = folder_path - click.confirm(customized_error_msg(ECustomizedError.CREATE_FOLDER_IF_NOT_EXIST), abort=True) create_folder_flag = True break else: diff --git a/app/utils/aggregated.py b/app/utils/aggregated.py index 725cb753..a6d13cfe 100644 --- a/app/utils/aggregated.py +++ b/app/utils/aggregated.py @@ -60,7 +60,7 @@ def get_file_info_by_geid(geid: list): def fit_terminal_width(string_to_format): - string_to_format = string_to_format.split('...') + string_to_format = string_to_format.rsplit('...') current_len = 0 sentence = '' terminal_width = shutil.get_terminal_size().columns diff --git a/pyproject.toml b/pyproject.toml index d373d752..eab325d4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "app" -version = "2.8.4" +version = "2.8.5" description = "This service is designed to support pilot platform" authors = ["Indoc Systems"]