Skip to content

Commit 0950e40

Browse files
committed
Catch error when Glances stop
1 parent 5ed8764 commit 0950e40

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

glances/outputs/static/css/style.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,13 @@ body {
144144
#processlist-plugin .table-cell {
145145
padding: 0px 5px 0px 5px;
146146
white-space: nowrap;
147+
}
147148

148149
#vms-plugin .table-cell {
149150
padding: 0px 10px 0px 10px;
150151
white-space: nowrap;
151152
}
152-
}
153+
153154
#containers-plugin .table-cell {
154155
padding: 0px 10px 0px 10px;
155156
white-space: nowrap;

glances/outputs/static/public/glances.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

glances/plugins/vms/engines/multipass.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,13 @@ def update_version(self):
4141
# "multipass": "1.13.1",
4242
# "multipassd": "1.13.1"
4343
# }
44-
ret = orjson.loads(secure_popen(f'{MULTIPASS_PATH} {MULTIPASS_VERSION_OPTIONS}'))
45-
return ret.get('multipass', None)
44+
ret_cmd = secure_popen(f'{MULTIPASS_PATH} {MULTIPASS_VERSION_OPTIONS}')
45+
try:
46+
ret = orjson.loads(ret_cmd)
47+
except orjson.JSONDecodeError:
48+
return {}
49+
else:
50+
return ret.get('multipass', None)
4651

4752
def update_info(self):
4853
# > multipass info --format json
@@ -80,7 +85,13 @@ def update_info(self):
8085
# }
8186
# }
8287
# }
83-
return orjson.loads(secure_popen(f'{MULTIPASS_PATH} {MULTIPASS_INFO_OPTIONS}')).get('info')
88+
ret_cmd = secure_popen(f'{MULTIPASS_PATH} {MULTIPASS_INFO_OPTIONS}')
89+
try:
90+
ret = orjson.loads(ret_cmd)
91+
except orjson.JSONDecodeError:
92+
return {}
93+
else:
94+
return ret.get('info', {})
8495

8596
def update(self, all_tag) -> Tuple[Dict, List[Dict]]:
8697
"""Update Vm stats using the input method."""

0 commit comments

Comments
 (0)