Skip to content

Commit

Permalink
Merge pull request #63 from colinodell/fix/remove_key_error
Browse files Browse the repository at this point in the history
fix: add safe get on dnsInfo to avoid raise TypeError
  • Loading branch information
colinodell authored Aug 13, 2021
2 parents 922cf66 + 981da39 commit 5ea6625
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions qnapstats/qnap_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,10 @@ def get_system_stats(self):
"err_packets": int(root["err_packet" + i])
}

for dns in root["dnsInfo"]["DNS_LIST"]:
details["dns"].append(dns)
dnsInfo = root.get("dnsInfo")
if dnsInfo:
for dns in dnsInfo["DNS_LIST"]:
details["dns"].append(dns)

return details

Expand Down

0 comments on commit 5ea6625

Please sign in to comment.