Commit 25d9885c authored by Jérome Perrin's avatar Jérome Perrin

PortalTransforms: py3 WIP 🚧

parent edcda582
......@@ -35,7 +35,8 @@ class commandtransform:
os.mkdir(tmpdir)
filename = kwargs.get("filename", '')
fullname = join(tmpdir, basename(filename))
filedest = open(fullname , "wb").write(data)
with open(fullname , "wb") as f:
f.write(data)
return tmpdir, fullname
def subObjects(self, tmpdir):
......@@ -51,7 +52,8 @@ class commandtransform:
def fixImages(self, path, images, objects):
for image in images:
objects[image] = open(join(path, image), 'rb').read()
with open(join(path, image), 'rb') as f:
objects[image] = f.read()
def cleanDir(self, tmpdir):
shutil.rmtree(tmpdir)
......@@ -99,7 +101,7 @@ class popentransform:
cin, couterr = os.popen4(command, 'b')
if self.useStdin:
cin.write(str(data))
cin.write(bytes(data))
status = cin.close()
......
......@@ -36,9 +36,7 @@ class ImageMagickTransforms:
stderr=subprocess.PIPE,
close_fds=True)
try:
# XXX: The only portable way is to pass what stdin.write can accept,
# which is a string for PIPE.
image, err = p.communicate(str(orig))
image, err = p.communicate(bytes(orig))
finally:
del p
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment