mirror of
https://github.com/openharmony/developtools_syscap_codec.git
synced 2026-08-26 17:56:33 -04:00
解决告警
Signed-off-by: aodongbiao <aodongbiao@huawei.com> Change-Id: I8e10789dca94bef1390f13a4f6f53ba63e9b29cf
This commit is contained in:
@@ -78,15 +78,15 @@ def read_value_from_json(filepath: str,
|
||||
if not os.path.isfile(filepath):
|
||||
print('error: "{}" is not a file.')
|
||||
return
|
||||
f = open(filepath, 'r')
|
||||
data = json.load(f)
|
||||
for key in key_hierarchy:
|
||||
try:
|
||||
data = data[key]
|
||||
except KeyError:
|
||||
return
|
||||
finally:
|
||||
f.close()
|
||||
with open(filepath, 'r', encoding='utf-8') as f:
|
||||
data = json.load(f)
|
||||
for key in key_hierarchy:
|
||||
try:
|
||||
data = data[key]
|
||||
except KeyError:
|
||||
return
|
||||
finally:
|
||||
pass
|
||||
data = [post_handler(x) for x in data if len(x) != 0 and not x.isspace()]
|
||||
if len(data) != 0:
|
||||
result_dict[filepath] = data
|
||||
|
||||
Reference in New Issue
Block a user