From b2b559e73b67427861491dd3c10a8eecb541d66b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=81=AB=E7=84=9A=20=E5=AF=8C=E8=89=AF?= Date: Fri, 2 Dec 2022 16:30:58 +0800 Subject: [PATCH] browser: tolerate missing HDF5 metadata --- artiq/browser/files.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/artiq/browser/files.py b/artiq/browser/files.py index 46bf10b3f..4e3dd581a 100644 --- a/artiq/browser/files.py +++ b/artiq/browser/files.py @@ -102,13 +102,14 @@ class Hdf5FileSystemModel(QtWidgets.QFileSystemModel): h5 = open_h5(info) if h5 is not None: try: - expid = pyon.decode(h5["expid"][()]) - start_time = datetime.fromtimestamp(h5["start_time"][()]) + expid = pyon.decode(h5["expid"][()]) if "expid" in h5 else dict() + start_time = datetime.fromtimestamp(h5["start_time"][()]) if "start_time" in h5 else "" v = ("artiq_version: {}\nrepo_rev: {}\nfile: {}\n" "class_name: {}\nrid: {}\nstart_time: {}").format( - h5["artiq_version"][()], expid["repo_rev"], - expid.get("file", ""), expid["class_name"], - h5["rid"][()], start_time) + h5["artiq_version"][()] if "artiq_version" in h5 else "", + expid.get("repo_rev", ""), + expid.get("file", ""), expid.get("class_name", ""), + h5["rid"][()] if "rid" in h5 else "", start_time) return v except: logger.warning("unable to read metadata from %s", @@ -174,14 +175,14 @@ class FilesDock(QtWidgets.QDockWidget): logger.debug("loading datasets from %s", info.filePath()) with f: try: - expid = pyon.decode(f["expid"][()]) - start_time = datetime.fromtimestamp(f["start_time"][()]) + expid = pyon.decode(f["expid"][()]) if "expid" in f else dict() + start_time = datetime.fromtimestamp(f["start_time"][()]) if "start_time" in f else "" v = { - "artiq_version": f["artiq_version"][()], - "repo_rev": expid["repo_rev"], + "artiq_version": f["artiq_version"][()] if "artiq_version" in f else "", + "repo_rev": expid.get("repo_rev", ""), "file": expid.get("file", ""), - "class_name": expid["class_name"], - "rid": f["rid"][()], + "class_name": expid.get("class_name", ""), + "rid": f["rid"][()] if "rid" in f else "", "start_time": start_time, } self.metadata_changed.emit(v)