diff --git a/BAC0/core/devices/Device.py b/BAC0/core/devices/Device.py index ba174cc..49808fd 100755 --- a/BAC0/core/devices/Device.py +++ b/BAC0/core/devices/Device.py @@ -1067,6 +1067,7 @@ async def initialize_device_from_db(self): # Save important properties for reuse if self.properties.db_name: dbname = self.properties.db_name + self._props = self.read_dev_prop(self.properties.db_name) else: self.log("Missing argument DB", level="info") raise ValueError("Please provide db name using device.load_db('name')") @@ -1074,7 +1075,6 @@ async def initialize_device_from_db(self): # network = self.properties.network pss = self.properties.pss - self._props = self.read_dev_prop(self.properties.db_name) self.points = [] for point in self.points_from_sql(self.properties.db_name): try: diff --git a/BAC0/db/sql.py b/BAC0/db/sql.py index 64b3dea..b4c6e69 100644 --- a/BAC0/db/sql.py +++ b/BAC0/db/sql.py @@ -291,5 +291,9 @@ def read_dev_prop(self, device_name): Device properties retrieved from pickle """ self.log("Reading prop from DB file", level="debug") - with open(f"{device_name}.bin", "rb") as file: - return pickle.load(file)["device"] + try: + with open(f"{device_name}.bin", "rb") as file: + return pickle.load(file)["device"] + except EOFError: + self._log.error("Error reading device properties") + raise ValueError