Skip to content

Commit 2ce7945

Browse files
Merge pull request #209 from linuxmaniac/vseva/208
tools/view_stats.py: exit properly when no info is on Redis
2 parents 030dc72 + b2a08f3 commit 2ce7945

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

tools/view_stats.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#This utility prints PyHSS stats stored in Redis
1+
# This utility prints PyHSS stats stored in Redis
22
import yaml
33
import sys
44
with open(sys.path[0] + '/../config.yaml') as stream:
@@ -15,12 +15,13 @@
1515

1616
print("\n\nDiameter Peers:")
1717
ActivePeerDict = r.get('ActivePeerDict')
18-
if len(ActivePeerDict) == 0:
18+
if ActivePeerDict is None or len(ActivePeerDict) == 0:
1919
print("No connected peers.")
20+
sys.exit()
2021
ActivePeerDict = json.loads(ActivePeerDict)
2122

2223
for keys in ActivePeerDict:
2324
print(keys)
2425
for subkeys in ActivePeerDict[keys]:
2526
print("\t" + str(subkeys) + ": \t" + str(ActivePeerDict[keys][subkeys]))
26-
print('\n')
27+
print('\n')

0 commit comments

Comments
 (0)