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

wip

parent f5e23695
......@@ -28,6 +28,7 @@ from slapos.runner.process import Popen
from passlib.apache import HtpasswdFile
import slapos.slap
from slapos.grid.utils import md5digest
from slapos.util import str2bytes
logger = logging.getLogger('slaprunner')
......@@ -764,7 +765,8 @@ def isText(file):
"""Return True if the mimetype of file is Text"""
if not os.path.exists(file):
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))
try:
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