Commit 9498271d authored by Sébastien Luttringer's avatar Sébastien Luttringer
Browse files

fix python2.6 doesn"t allow keywords args for str.encode

parent 01c677ab
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -803,13 +803,13 @@ class PackageImage(Image):
        if gendescription:
            arrow(u"Generating description file in %s" % directory)
            with open(os.path.join(directory, "description"), "w") as f:
                f.write((istemplate.description % self._metadata).encode('utf-8'))
                f.write((istemplate.description % self._metadata).encode("UTF-8"))
        # launch payload extraction
        if payload:
            for payname in self.payload:
                # here we need to decode payname which is in unicode to escape
                # tarfile to encode filename of file inside tarball inside unicode
                dest = os.path.join(directory, "payload", payname.encode("utf-8"))
                dest = os.path.join(directory, "payload", payname.encode("UTF-8"))
                arrow(u"Extracting payload %s in %s" % (payname, dest))
                self.payload[payname].extract(dest, force=force)

+1 −1
Original line number Diff line number Diff line
@@ -59,7 +59,7 @@ def out(message="", fd=sys.stdout, endl=os.linesep, flush=True):
    # convert unicode into str before write
    # this can cause issue on python 2.6
    if type(message) == unicode:
        message = message.encode(locale.getpreferredencoding(), errors='replace')
        message = message.encode(locale.getpreferredencoding(), "replace")
    # printing
    fd.write("%s%s" % (message, endl))
    if flush: