from bb.ui.crumbs.persistenttooltip import PersistentTooltip
import bb.ui.crumbs.utils
+hobVer = 20120530
+
class Configuration:
'''Represents the data structure of configuration.'''
self.split_proxy("cvs", template.getVar("CVS_PROXY_HOST") + ":" + template.getVar("CVS_PROXY_PORT"))
def save(self, template, defaults=False):
+ template.setVar("VERSION", "%s" % hobVer)
# bblayers.conf
template.setVar("BBLAYERS", " ".join(self.layers))
# local.conf
def initiate_new_build_async(self):
self.switch_page(self.MACHINE_SELECTION)
- if self.load_template(TemplateMgr.convert_to_template_pathfilename("default", ".hob/")) == None:
+ if self.load_template(TemplateMgr.convert_to_template_pathfilename("default", ".hob/")) == False:
self.handler.init_cooker()
self.handler.set_extra_inherit("image_types")
self.handler.generate_configuration()
def load_template(self, path):
if not os.path.isfile(path):
- return None
+ return False
self.template = TemplateMgr()
+ # check compatibility
+ tempVer = self.template.getVersion(path)
+ if not tempVer or int(tempVer) < hobVer:
+ self.template.destroy()
+ self.template = None
+ return False
+
try:
self.template.load(path)
self.configuration.load(self.template)
return self.dictionary[var]
else:
return ""
-
+
+ def getVersion(self):
+ contents = ConfigFile.readFile(self)
+
+ pattern = "^\s*(\S+)\s*=\s*(\".*?\")"
+
+ for line in contents:
+ match = re.search(pattern, line)
+ if match:
+ if match.group(1) == "VERSION":
+ return match.group(2).strip('"')
+ return None
+
def load(self):
contents = ConfigFile.readFile(self)
self.dictionary.clear()
self.image_bb.save()
self.template_hob.save()
+ def getVersion(self, path):
+ return HobTemplateFile(path).getVersion()
+
def load(self, path):
self.template_hob = HobTemplateFile(path)
self.dictionary = self.template_hob.load()