summaryrefslogtreecommitdiff
path: root/cxmanage_api/image.py
diff options
context:
space:
mode:
Diffstat (limited to 'cxmanage_api/image.py')
-rw-r--r--cxmanage_api/image.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/cxmanage_api/image.py b/cxmanage_api/image.py
index a6456d4..7be88fb 100644
--- a/cxmanage_api/image.py
+++ b/cxmanage_api/image.py
@@ -79,7 +79,7 @@ class Image(object):
raise ValueError("File %s does not exist" % filename)
if (simg == None):
- contents = open(filename).read()
+ contents = open(filename, "rb").read()
self.simg = has_simg(contents)
else:
self.simg = simg
@@ -108,7 +108,7 @@ class Image(object):
filename = self.filename
# Create new image if necessary
if (not self.simg):
- contents = open(filename).read()
+ contents = open(filename, "rb").read()
# Figure out daddr
if (self.daddr != None):
daddr = self.daddr
@@ -118,11 +118,11 @@ class Image(object):
skip_crc32=self.skip_crc32, align=align,
version=self.version)
filename = temp_file()
- with open(filename, "w") as file_:
+ with open(filename, "wb") as file_:
file_.write(simg)
# Make sure the simg was built correctly
- if (not valid_simg(open(filename).read())):
+ if (not valid_simg(open(filename, "rb").read())):
raise InvalidImageError("%s is not a valid SIMG" %
os.path.basename(self.filename))
@@ -141,7 +141,7 @@ class Image(object):
if (self.simg):
return os.path.getsize(self.filename)
else:
- contents = open(self.filename).read()
+ contents = open(self.filename, "rb").read()
align = (self.type in ["CDB", "BOOT_LOG"])
simg = create_simg(contents, skip_crc32=True, align=align)
return len(simg)
@@ -171,7 +171,7 @@ class Image(object):
if (self.type in ["CDB", "BOOT_LOG"]):
# Look for "CDBH"
- contents = open(self.filename).read()
+ contents = open(self.filename, "rb").read()
if (self.simg):
contents = get_simg_contents(contents)
if (contents[:4] != "CDBH"):