Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
nexedi
/
slapos.toolbox
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
3
Wiki
Network
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit eaad8c02
authored
2019-07-22 14:54:26 +0200
by
Bryton Lacquement
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fixup! Add support for Python 3
1 parent
1c8269b2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
1 deletions
slapos/runner/utils.py
slapos/runner/utils.py
View file @
eaad8c0
...
...
@@ -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
))
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment