diff --git a/setup.py b/setup.py index 6b61005..1c8f2ab 100644 --- a/setup.py +++ b/setup.py @@ -16,6 +16,7 @@ 'tabulate>=0.7.5', 'setuptools', 'pytz', + 'tzlocal', ] tests_require = [ diff --git a/stacks/__about__.py b/stacks/__about__.py index 73cda9f..4d874e7 100644 --- a/stacks/__about__.py +++ b/stacks/__about__.py @@ -1,4 +1,4 @@ -__version__ = '0.4.0' +__version__ = '0.4.1' __licence__ = 'MIT' __url__ = 'https://stacks.tools' __maintainer__ = 'Vaidas Jablonskis' diff --git a/stacks/cf.py b/stacks/cf.py index 9ae075e..3e93edd 100644 --- a/stacks/cf.py +++ b/stacks/cf.py @@ -13,6 +13,7 @@ import hashlib import boto import pytz +import tzlocal from os import path from jinja2 import meta @@ -302,9 +303,10 @@ def print_events(conn, stack_name, follow, lines=100, from_dt=datetime.fromtimes events, next_token = get_events(conn, stack_name, next_token) status = get_stack_status(conn, stack_name) if follow: - events_display = [(ev.timestamp, ev.resource_status, ev.resource_type, + normalize_events_timestamps(events) + events_display = [(ev.timestamp.astimezone(tzlocal.get_localzone()), ev.resource_status, ev.resource_type, ev.logical_resource_id, ev.resource_status_reason) for ev in events - if ev.event_id not in seen_ids and ev.timestamp.replace(tzinfo=pytz.UTC) >= from_dt] + if ev.event_id not in seen_ids and ev.timestamp >= from_dt] if len(events_display) > 0: print(tabulate(events_display, tablefmt='plain'), flush=True) seen_ids |= set([event.event_id for event in events]) @@ -350,3 +352,8 @@ def stack_exists(conn, stack_name): if status == 'DELETE_COMPLETE' or status is None: return False return True + + +def normalize_events_timestamps(events): + for ev in events: + ev.timestamp = ev.timestamp.replace(tzinfo=pytz.UTC)