[yocto] Error while trying to read environment variable from a recipe file
Bipnesh, Abhinav (Abhinav)
abhinavbipnesh at avaya.com
Tue Feb 10 02:24:45 PST 2015
Hi All,
I was trying to read some of the environment variables from a recipe file using below python code
PACKAGES = "{TEST_PACKAGE}"
python __anonymous () {
packages = []
buildScriptVersion = os.environ['MajorVersion'] + "." + os.environ['MinorVersion']
buildID = os.environ['BuildID']
buildOffSet = os.environ['BuildOffsetNum']
buildNum = int(buildID) - int(buildOffSet)
if buildNum <= 0:
buildNum = 1
Num = os.environ['Num']
version = buildScriptVersion + "." + sprintNum + "." + str(buildNum)
packageName = "test-" + version
d.setVar("TEST_PACKAGE", " ".join(packages))
}
But while running I am getting below error
0001:def __anon_29__test_bb(d):
0002: packages = []
*** 0003: buildScriptVersion = os.environ['MajorVersion'] + "." + os.environ['MinorVersion']
0004: buildID = os.environ['BuildID']
0005: buildOffSet = os.environ['BuildOffsetNum']
0006: buildNum = int(buildID) - int(buildOffSet)
0007: if buildNum <= 0:
File: '/usr/lib64/python2.7/UserDict.py', lineno: 23, function: __getitem__
0019: if key in self.data:
0020: return self.data[key]
0021: if hasattr(self.__class__, "__missing__"):
0022: return self.__class__.__missing__(self, key)
*** 0023: raise KeyError(key)
0024: def __setitem__(self, key, item): self.data[key] = item
0025: def __delitem__(self, key): del self.data[key]
0026: def clear(self): self.data.clear()
0027: def copy(self):
Exception: KeyError: 'MajorVersion'
So any thoughts to fix this issue. As we need to have a package name with such variable which will be set in the environment at run time.
Thanks,
Abhinav
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.yoctoproject.org/pipermail/yocto/attachments/20150210/f18f2e05/attachment.html>
More information about the yocto
mailing list