2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-31 06:15:24 +00:00

lib: fix crit-recode fix for Python 2

The recent fix to make Jenkins run crit-recode again broke
Python 2 support (because Python 2 based CI was not running).

This should fix the Python 2 based test run.

Signed-off-by: Adrian Reber <areber@redhat.com>
This commit is contained in:
Adrian Reber
2021-03-20 11:35:32 +00:00
committed by Andrei Vagin
parent 228e510d21
commit b82f222d6b
2 changed files with 18 additions and 4 deletions

View File

@@ -42,6 +42,7 @@ import base64
import struct
import os
import array
import sys
from . import magic
from . import pb
@@ -284,9 +285,15 @@ class ghost_file_handler:
size = len(pb_str)
f.write(struct.pack('i', size))
f.write(pb_str)
f.write(base64.decodebytes(str.encode(item['extra'])))
if (sys.version_info > (3, 0)):
f.write(base64.decodebytes(str.encode(item['extra'])))
else:
f.write(base64.decodebytes(item['extra']))
else:
f.write(base64.decodebytes(str.encode(item['extra'])))
if (sys.version_info > (3, 0)):
f.write(base64.decodebytes(str.encode(item['extra'])))
else:
f.write(base64.decodebytes(item['extra']))
def dumps(self, entries):
f = io.BytesIO('')

View File

@@ -3,6 +3,7 @@ import collections
import os
import quopri
import socket
import sys
from ipaddress import IPv4Address, IPv6Address, ip_address
from google.protobuf.descriptor import FieldDescriptor as FD
@@ -246,11 +247,17 @@ def encode_dev(field, value):
def encode_base64(value):
return base64.encodebytes(value).decode()
if (sys.version_info > (3, 0)):
return base64.encodebytes(value).decode()
else:
return base64.encodebytes(value)
def decode_base64(value):
return base64.decodebytes(str.encode(value))
if (sys.version_info > (3, 0)):
return base64.decodebytes(str.encode(value))
else:
return base64.decodebytes(value)
def encode_unix(value):