diff options
author | Martin Peres <martin.peres@linux.intel.com> | 2017-03-10 14:40:49 +0200 |
---|---|---|
committer | Martin Peres <martin.peres@linux.intel.com> | 2017-10-04 17:48:28 +0300 |
commit | dd0d057c485c0c0e634f0bf9813cb8c307102b69 (patch) | |
tree | 58325a31579745b20493221b4f8f9b4c97114316 | |
parent | a6e791f2c2b5d08aecb08000f5a2e28a7e819856 (diff) |
smartezbench: introduce a mechanism to update the state's format
-rw-r--r-- | python-modules/ezbench/smartezbench.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/python-modules/ezbench/smartezbench.py b/python-modules/ezbench/smartezbench.py index e50e2cc..724f945 100644 --- a/python-modules/ezbench/smartezbench.py +++ b/python-modules/ezbench/smartezbench.py @@ -291,6 +291,21 @@ class SmartEzbench: self.__log(Criticality.EE, "Cannot release the lock: " + str(e)) pass + def __update_state_version__(self): + upgraded = False + if self.state.get("version", 0) == 0: + self.__log(Criticality.II, "state: v0 -> v1: add a version parameter") + self.state['version'] = 1 + upgraded = True + + latest_version = 1 + if self.state.get("version", 0) > latest_version: + msg = "The state's version is higher than the latest supported version: {} vs {}" + raise ValueError(msg.format(self.state.get("version", 0), latest_version)) + + if upgraded: + self.__save_state() + def __reload_state_unlocked(self): # check if a report already exists try: @@ -301,6 +316,8 @@ class SmartEzbench: except Exception as e: self.__log(Criticality.EE, "Exception while reading the state: " + str(e)) pass + + self.__update_state_version__() return True except IOError as e: self.__log(Criticality.WW, "Cannot open the state file: " + str(e)) |