Skip to content

Commit

Permalink
Better timezone management (#575)
Browse files Browse the repository at this point in the history
  • Loading branch information
iakov-aws authored Jul 6, 2023
1 parent cf74598 commit f870553
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cfn-templates/cid-cfn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ Parameters:
CidVersion:
Type: String
MinLength: 5
Default: 0.2.21
Default: 0.2.22
Description: A version of CID package
Suffix:
Type: String
Expand Down
2 changes: 1 addition & 1 deletion cid/_version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@

__version__ = '0.2.21'
__version__ = '0.2.22'
10 changes: 7 additions & 3 deletions cid/helpers/quicksight/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1067,11 +1067,15 @@ def ensure_dataset_refresh_schedule(self, dataset_id, schedules: list):
if exec_env()['terminal'] in ('lambda'):
schedule_frequency_timezone = get_parameters().get("timezone", timezone.get_default_timezone())
else:
default_timezone = timezone.get_default_timezone()
schedule_frequency_timezone = get_parameter("timezone",
message='Please select timezone for datasets scheduled refresh time',
choices=timezone.get_all_timezones(),
default=timezone.get_default_timezone()
message='Please select timezone for datasets scheduled refresh.',
choices=sorted(list(set(timezone.get_all_timezones() + [default_timezone]))),
default=default_timezone
)
if not schedule_frequency_timezone:
logger.warning(f'Cannot get timezone. Please provide --timezone parameter. Please make sure scheduled refresh is configured manualy.')
return

for schedule in schedules:

Expand Down
2 changes: 1 addition & 1 deletion cid/helpers/randtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

def pseudo_random_generator(hashable_string: str, maximum: int=100) -> int:
"""Gernerate a pseudo random integer number, but the same for any given hashable_string identifier """
hash_hex = hashlib.md5(bytes(hashable_string, "utf-8"), usedforsecurity=False).hexdigest()[:16] # nosec B303 - not used for security
hash_hex = hashlib.md5(bytes(hashable_string, "utf-8")).hexdigest()[:16] # nosec B303, B324 - not used for security
bigint_value = int.from_bytes(bytes.fromhex(hash_hex), 'little', signed=True)
return bigint_value % int(maximum)

Expand Down
5 changes: 4 additions & 1 deletion cid/helpers/timezone.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,7 @@ def get_default_timezone():
def get_all_timezones():
"""Get all zones"""
# zoneinfo is not working with 3.7, 3.8
return sorted(list(win_tz.values()))

return sorted(list(set(
list(win_tz.values()) + list(MAPPING_REGION_2_TIMEZONE.values())
)))

0 comments on commit f870553

Please sign in to comment.