summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVu Cong Tuan <tuanvc@vn.fujitsu.com>2018-07-05 10:35:31 +0700
committerVu Cong Tuan <tuanvc@vn.fujitsu.com>2018-07-10 07:58:45 +0700
commit7be92d78fc4a804326e4013a28d1741316998c53 (patch)
tree041cc613579a87fa98e7f9a66e862c4835116b24
parent7201fdce8716f7f81dd060b32c74acd922ffe57e (diff)
Replace file() with open() for Python 3 compatibility2018.08.0
The built-in named 'file' has been removed since Python 3.0 [1] This patch replaces it by 'open' which is the same under Python 2 and 3. [1] https://docs.python.org/release/3.0/whatsnew/3.0.html#builtins Change-Id: Ib2abbd0f6aea4423acae0c7dceccf1ef67c1caae
Notes
Notes (review): Code-Review+1: Al Bailey <al.bailey@windriver.com> Code-Review+1: Felipe de Jesus Ruiz Garcia <felipe.de.jesus.ruiz.garcia@intel.com> Code-Review+2: Dean Troyer <dtroyer@gmail.com> Code-Review+1: Yan Chen <yan.chen@intel.com> Workflow+1: Al Bailey <al.bailey@windriver.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Mon, 16 Jul 2018 12:45:43 +0000 Reviewed-on: https://review.openstack.org/580265 Project: openstack/stx-fault Branch: refs/heads/master
-rwxr-xr-xfm-common/sources/fm_db_sync_event_suppression.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/fm-common/sources/fm_db_sync_event_suppression.py b/fm-common/sources/fm_db_sync_event_suppression.py
index a859f6d..be8d78a 100755
--- a/fm-common/sources/fm_db_sync_event_suppression.py
+++ b/fm-common/sources/fm_db_sync_event_suppression.py
@@ -105,15 +105,15 @@ EVENT_TYPES_FILE = get_events_yaml_filename()
105if not os.path.isfile(EVENT_TYPES_FILE): 105if not os.path.isfile(EVENT_TYPES_FILE):
106 exit (-1) 106 exit (-1)
107 107
108stream = file(EVENT_TYPES_FILE, 'r') 108with open(EVENT_TYPES_FILE, 'r') as stream:
109event_types = yaml.load(stream) 109 event_types = yaml.load(stream)
110 110
111for alarm_id in event_types: 111for alarm_id in event_types:
112 if isinstance(alarm_id, float): 112 if isinstance(alarm_id, float):
113 # force 3 digits after the decimal point, 113 # force 3 digits after the decimal point,
114 # to include trailing zero's (ex.: 200.010) 114 # to include trailing zero's (ex.: 200.010)
115 formatted_alarm_id = "{:.3f}".format(alarm_id) 115 formatted_alarm_id = "{:.3f}".format(alarm_id)
116 event_types[formatted_alarm_id] = event_types.pop(alarm_id) 116 event_types[formatted_alarm_id] = event_types.pop(alarm_id)
117 117
118event_types = collections.OrderedDict(sorted(event_types.items())) 118event_types = collections.OrderedDict(sorted(event_types.items()))
119 119