Skip to content

Commit f4e6cd6

Browse files
Merge pull request #83 from HPCNow/main
froster v0.14.1
2 parents a7b6c1f + a758576 commit f4e6cd6

File tree

2 files changed

+42
-13
lines changed

2 files changed

+42
-13
lines changed

Diff for: froster/froster.py

+41-12
Original file line numberDiff line numberDiff line change
@@ -543,11 +543,9 @@ def set_credentials(self, aws: 'AWSBoto'):
543543
# Get the default credentials directory from the config file
544544
default_credentials_dir = self.__get_configuration_entry(
545545
'CREDENTIALS', 'credentials_dir')
546-
if default_credentials_dir is None:
547-
default_credentials_dir = os.path.join('~', '.aws')
548-
if not os.path.exists(os.path.expanduser(default_credentials_dir)):
549-
os.makedirs(os.path.expanduser(default_credentials_dir),
550-
exist_ok=True, mode=0o775)
546+
547+
if not os.path.exists(default_credentials_dir):
548+
default_credentials_dir = None
551549

552550
# Ask user to enter the path to a aws credentials directory
553551
credentials_dir_question = [
@@ -912,10 +910,17 @@ def set_email(self):
912910
try:
913911
log(f'\n*** SET EMAIL ***\n')
914912

913+
default_email = self.__get_configuration_entry('USER', 'email')
914+
915+
# Email pattern
916+
pattern = r'^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$'
917+
if re.match(pattern, default_email) is None:
918+
default_email = None
919+
915920
# Ask the user for their email
916921
email = inquirer.text(
917922
message="Enter your email",
918-
default=self.__get_configuration_entry('USER', 'email'),
923+
default=default_email,
919924
validate=self.__inquirer_check_email_format)
920925

921926
# Print for a new line when prompting
@@ -946,10 +951,16 @@ def set_endpoint(self):
946951
elif self.provider == 'GCS':
947952
endpoint = 'https://storage.googleapis.com'
948953
else:
954+
default_endpoint = self.__get_configuration_entry(
955+
'S3', 'endpoint', fallback=None)
956+
957+
if default_endpoint == '':
958+
default_endpoint = None
959+
949960
# Get the user answer
950961
endpoint = inquirer.text(
951962
message=f'Enter the {self.provider} endpoint',
952-
default=self.__get_configuration_entry('S3', 'endpoint'),
963+
default=default_endpoint,
953964
validate=self.__inquirer_check_required)
954965

955966
# Ensure the endpoint starts with "https://" for IDrive
@@ -997,11 +1008,16 @@ def set_provider(self):
9971008
list_of_providers = PROVIDERS_LIST
9981009
list_of_providers.append('+ Create new provider')
9991010

1011+
default_provider = self.__get_configuration_entry(
1012+
'S3', 'provider', fallback='AWS')
1013+
1014+
if default_provider == '':
1015+
default_provider = None
1016+
10001017
# Get the user answer
10011018
provider = inquirer.list_input(
10021019
"Choose your s3 provider",
1003-
default=self.__get_configuration_entry(
1004-
'S3', 'provider', fallback='AWS'),
1020+
default=default_provider,
10051021
choices=list_of_providers)
10061022

10071023
if provider == '+ Create new provider':
@@ -1061,10 +1077,15 @@ def set_s3(self, aws: "AWSBoto"):
10611077
# Store aws s3 bucket in the config object
10621078
self.__set_configuration_entry('S3', 'bucket_name', s3_bucket)
10631079

1080+
default_archive_dir = self.__get_configuration_entry('S3', 'archive_dir', fallback='froster')
1081+
1082+
if default_archive_dir == '':
1083+
default_archive_dir = 'froster'
1084+
10641085
# Get user answer
10651086
archive_dir = inquirer.text(
10661087
message='Enter the directory name inside S3 bucket',
1067-
default=self.__get_configuration_entry('S3', 'archive_dir', fallback='froster'),
1088+
default=default_archive_dir,
10681089
validate=self.__inquirer_check_required)
10691090

10701091
# Print newline after this prompt
@@ -1076,6 +1097,9 @@ def set_s3(self, aws: "AWSBoto"):
10761097
default_storage_class = self.__get_configuration_entry(
10771098
'S3', 'storage_class', fallback='DEEP_ARCHIVE')
10781099

1100+
if default_storage_class == '':
1101+
default_storage_class = None
1102+
10791103
if self.provider == 'AWS':
10801104
storage_class = inquirer.list_input(
10811105
"Choose the AWS S3 storage class",
@@ -1146,13 +1170,18 @@ def set_shared(self):
11461170
# and check if we need to move cfg.archive_json_file_name and configuration to the shared directory
11471171
if is_shared:
11481172

1173+
default_shared_dir = self.__get_configuration_entry(
1174+
'SHARED', 'shared_dir', fallback=None)
1175+
1176+
if default_shared_dir == '':
1177+
default_shared_dir = None
1178+
11491179
# Ask user to enter the path to a shared config directory
11501180
# TODO: make this inquiring in shortchut mode once this PR is merged: https://github.com/magmax/python-inquirer/pull/543
11511181
shared_config_dir_question = [
11521182
inquirer.Path(
11531183
'shared_dir', message='Enter the path to a shared config directory',
1154-
default=self.__get_configuration_entry(
1155-
'SHARED', 'shared_dir', fallback=None),
1184+
default=default_shared_dir,
11561185
validate=self.__inquirer_check_path_exists)
11571186
]
11581187

Diff for: pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
44

55
[tool.poetry]
66
name = "froster"
7-
version = "0.14.0"
7+
version = "0.14.1"
88
description = "Froster is a tool for easy data transfer between local file systems and AWS S3 storage."
99
authors = ["Victor Machado <[email protected]>"]
1010
readme = "README.md"

0 commit comments

Comments
 (0)