Commit eaad8c02 authored by Bryton Lacquement's avatar Bryton Lacquement 🚪

fixup! Add support for Python 3

parent 1c8269b2
...@@ -28,6 +28,7 @@ from slapos.runner.process import Popen ...@@ -28,6 +28,7 @@ from slapos.runner.process import Popen
from passlib.apache import HtpasswdFile from passlib.apache import HtpasswdFile
import slapos.slap import slapos.slap
from slapos.grid.utils import md5digest from slapos.grid.utils import md5digest
from slapos.util import str2bytes
logger = logging.getLogger('slaprunner') logger = logging.getLogger('slaprunner')
...@@ -764,7 +765,8 @@ def isText(file): ...@@ -764,7 +765,8 @@ def isText(file):
"""Return True if the mimetype of file is Text""" """Return True if the mimetype of file is Text"""
if not os.path.exists(file): if not os.path.exists(file):
return False return False
text_range = ''.join(map(chr, [7, 8, 9, 10, 12, 13, 27] + range(0x20, 0x100))) text_range = str2bytes(''.join(map(chr, [7, 8, 9, 10, 12, 13, 27]
+ list(range(0x20, 0x100)))))
is_binary_string = lambda bytes: bool(bytes.translate(None, text_range)) is_binary_string = lambda bytes: bool(bytes.translate(None, text_range))
try: try:
return not is_binary_string(open(file).read(1024)) return not is_binary_string(open(file).read(1024))
......
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