Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions app/commands/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions app/resources/custom_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.'
),
Expand Down
8 changes: 7 additions & 1 deletion app/services/file_manager/file_upload/file_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion app/utils/aggregated.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"]

Expand Down