Skip to content

Commit c994f20

Browse files
committed
Minor updates to be less strict on local log file names, as well as handling devices with no log files in them.
1 parent d7d31ca commit c994f20

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

canedge_datasource/CanedgeFileSystem.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def get_device_log_files(self, device, reverse: bool = False):
4242

4343
def path_to_pars(self, path):
4444
"""Matches as much as possible of path to CANedge pars (device id, session, split, extension)"""
45-
pattern = r"^(?P<device_id>[0-9A-F]{8})?((/)(?P<session_no>\d{8}))?((/)(?P<split_no>\d{8})(?:-[0-9A-F]{8}){0,1}(?P<ext>\.(MF4|MFC|MFM|MFE)))?$"
45+
pattern = r"^(?P<device_id>[0-9A-F]{8})?((/)(?P<session_no>\d{8}))?((/)(?P<split_no>\d{8})(?:-[0-9A-F]{8}){0,1}(\S*)(?P<ext>\.(MF4|MFC|MFM|MFE)))?$"
4646
match = re.match(pattern, path, re.IGNORECASE)
4747
if match:
4848
return match.group("device_id"), match.group("session_no"), match.group("split_no"), match.group("ext")

canedge_datasource/search.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,17 @@ def get_logfile_comment(log_file):
5050
# Return list of device ids and meta comments (slow)
5151
for device in app.fs.get_device_ids():
5252
# Get most recent log file
53-
log_file, _, _ = next(app.fs.get_device_log_files(device=device, reverse=True), None)
54-
# Get log file comment
55-
if log_file is not None:
56-
comment = " " + get_logfile_comment(log_file)
57-
else:
53+
try:
54+
log_file, _, _ = next(app.fs.get_device_log_files(device=device, reverse=True), None)
55+
# Get log file comment
56+
if log_file is not None:
57+
comment = " " + get_logfile_comment(log_file)
58+
else:
59+
comment = ""
60+
except:
61+
print(f"Unable to list log files for {device} - review folder structure and log file names")
5862
comment = ""
63+
5964
res.append({"text": f"{device}{comment}", "value": device})
6065
elif req["search"] == "itf":
6166
# Return list of interfaces

0 commit comments

Comments
 (0)