Skip to content

Commit 9c3a772

Browse files
Added a bunch of exceptions during parameter parsing
1 parent 24273a5 commit 9c3a772

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

microscope/controllers/asi.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -172,14 +172,21 @@ def parse_info(
172172
settings = {}
173173
for item in items:
174174
match = re.search(pattern, item)
175-
settings[match.group("name").strip()] = {
176-
"value": match.group("value"),
175+
try:
176+
name = match.group("name")
177+
except AttributeError:
178+
_logger.warning(f"Error parsing info. No item name found on: {item}")
179+
continue
180+
try:
181+
value = match.group("value")
182+
except AttributeError:
183+
_logger.warning(f"Error parsing info. No item value found on: {item}")
184+
continue
185+
settings[name.strip()] = {
186+
"value": value,
177187
"command": None
178-
if not match.group("command")
179-
else match.group("command")[1:-1],
180-
"units": match.group("units")
181-
if len(match.group("units"))
182-
else None,
188+
if not match.group("command") else match.group("command")[1:-1],
189+
"units": match.group("units") if len(match.group("units")) else None,
183190
}
184191

185192
return settings

0 commit comments

Comments
 (0)