[Ezbench-dev] [PATCH 1/3] smartezbench: introduce a mechanism to update the state's format

Martin Peres martin.peres at linux.intel.com
Wed Mar 15 13:44:46 UTC 2017


---
 python-modules/ezbench/smartezbench.py | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/python-modules/ezbench/smartezbench.py b/python-modules/ezbench/smartezbench.py
index a3d6d67..e256c8f 100644
--- a/python-modules/ezbench/smartezbench.py
+++ b/python-modules/ezbench/smartezbench.py
@@ -291,6 +291,18 @@ class SmartEzbench:
             self.__log(Criticality.EE, "Cannot release the lock: " + str(e))
             pass
 
+    def __update_state_version__(self):
+        version = self.state.get("version", 0)
+
+        upgraded = False
+        if version == 0:
+            self.__log(Criticality.II, "state: v0 -> v1: add a version parameter")
+            self.state['version'] = 1
+            upgraded = True
+
+        if upgraded:
+            self.__save_state()
+
     def __reload_state_unlocked(self):
         # check if a report already exists
         try:
@@ -301,6 +313,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))
-- 
2.11.1



More information about the Ezbench-dev mailing list