summaryrefslogtreecommitdiffstats
path: root/meta/lib/oe
diff options
context:
space:
mode:
authorRoss Burton <ross.burton@intel.com>2016-02-24 13:31:40 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-02-28 11:32:35 +0000
commit4c1fe0cbcb98b0a69ad5b3a04432055d773ee4ba (patch)
tree03730b4965db04fc933ee6072d2c0f05bc4d32e1 /meta/lib/oe
parent6e779962f3846cbe5a5cb205f66b9bd9404f6d57 (diff)
downloadopenembedded-core-4c1fe0cbcb98b0a69ad5b3a04432055d773ee4ba.tar.gz
openembedded-core-4c1fe0cbcb98b0a69ad5b3a04432055d773ee4ba.tar.bz2
openembedded-core-4c1fe0cbcb98b0a69ad5b3a04432055d773ee4ba.zip
lib/oe/qa: add explicit exception for 'file isn't an ELF'
Signed-off-by: Ross Burton <ross.burton@intel.com>
Diffstat (limited to 'meta/lib/oe')
-rw-r--r--meta/lib/oe/qa.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/meta/lib/oe/qa.py b/meta/lib/oe/qa.py
index 2ad6c63bdc..4efa21fd80 100644
--- a/meta/lib/oe/qa.py
+++ b/meta/lib/oe/qa.py
@@ -1,3 +1,6 @@
+class NotELFFileError(Exception):
+ pass
+
class ELFFile:
EI_NIDENT = 16
@@ -23,7 +26,7 @@ class ELFFile:
def my_assert(self, expectation, result):
if not expectation == result:
#print "'%x','%x' %s" % (ord(expectation), ord(result), self.name)
- raise ValueError("%s is not an ELF" % self.name)
+ raise NotELFFileError("%s is not an ELF" % self.name)
def __init__(self, name, bits = 0):
self.name = name
@@ -32,7 +35,7 @@ class ELFFile:
def open(self):
if not os.path.isfile(self.name):
- raise ValueError("%s is not a normal file" % self.name)
+ raise NotELFFileError("%s is not a normal file" % self.name)
self.file = file(self.name, "r")
self.data = self.file.read(ELFFile.EI_NIDENT+4)
@@ -49,24 +52,24 @@ class ELFFile:
self.bits = 64
else:
# Not 32-bit or 64.. lets assert
- raise ValueError("ELF but not 32 or 64 bit.")
+ raise NotELFFileError("ELF but not 32 or 64 bit.")
elif self.bits == 32:
self.my_assert(self.data[ELFFile.EI_CLASS], chr(ELFFile.ELFCLASS32))
elif self.bits == 64:
self.my_assert(self.data[ELFFile.EI_CLASS], chr(ELFFile.ELFCLASS64))
else:
- raise ValueError("Must specify unknown, 32 or 64 bit size.")
+ raise NotELFFileError("Must specify unknown, 32 or 64 bit size.")
self.my_assert(self.data[ELFFile.EI_VERSION], chr(ELFFile.EV_CURRENT) )
self.sex = self.data[ELFFile.EI_DATA]
if self.sex == chr(ELFFile.ELFDATANONE):
- raise ValueError("self.sex == ELFDATANONE")
+ raise NotELFFileError("self.sex == ELFDATANONE")
elif self.sex == chr(ELFFile.ELFDATA2LSB):
self.sex = "<"
elif self.sex == chr(ELFFile.ELFDATA2MSB):
self.sex = ">"
else:
- raise ValueError("Unknown self.sex")
+ raise NotELFFileError("Unknown self.sex")
def osAbi(self):
return ord(self.data[ELFFile.EI_OSABI])