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

Submitted by Martin Peres on March 15, 2017, 1:44 p.m.

Details

Message ID 20170315134448.21577-2-martin.peres@linux.intel.com
State New
Headers show
Series "Separate user- and auto-requested tasks" ( rev: 1 ) in EzBench

Not browsing as part of any series.

Commit Message

Martin Peres March 15, 2017, 1:44 p.m.
---
 python-modules/ezbench/smartezbench.py | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

Patch hide | download patch | download mbox

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))