Skip to content

Commit f058a56

Browse files
authored
Merge pull request #62 from draios/dashboard-restore-skip-non-json
Catch exception for non-JSON items in Dashboard ZIP
2 parents 8f076fb + ea87603 commit f058a56

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

examples/restore_dashboards.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,18 @@
3939

4040
for info in zipf.infolist():
4141
data = zipf.read(info.filename)
42-
j = json.loads(data)
42+
try:
43+
j = json.loads(data)
44+
except ValueError:
45+
print 'Non-JSON item found in ZIP: ' + info.filename + ' (skipping)'
46+
continue
4347
k = {}
4448
for item in j.keys():
4549
if item in dashboard_conf_items:
4650
k[item] = j[item]
4751

4852
res = sdclient.create_dashboard_with_configuration(k)
49-
if res[0] == False:
53+
if res[0]:
54+
print 'Restored Dashboard named: ' + j['name']
55+
else:
5056
print "Dashboard creation failed for dashboard name %s with error %s" % (j['name'], res[1])

0 commit comments

Comments
 (0)