py3_forced
idziubenko 3 years ago
parent 69094e8971
commit 7872887ae3

@ -4999,10 +4999,10 @@ gettext -d cl_template "$*"
return False
def checkOsError(self, e, fn):
if hasattr(e, 'errno') and e.errno == os.errno.EPERM:
if hasattr(e, 'errno') and e.errno == errno.EPERM:
if self.checkVfat(fn):
return True
if hasattr(e, 'errno') and e.errno == os.errno.EACCES and \
if hasattr(e, 'errno') and e.errno == errno.EACCES and \
"var/calculate/remote" in fn:
return True
return False

@ -1051,6 +1051,7 @@ class SimpleDataVars(object):
return getList()(value)
if "table" in varType:
return map(getList(':'), value.split(','))
value = str(value, "UTF-8")
return fixEmpty(value).strip("'").strip('"')
def ZipVars(self, *argvVarNames, **kw):

@ -15,7 +15,7 @@
# limitations under the License.
import sys
import urllib2
import urllib.request as urllib2
import re
import time
import os

@ -302,7 +302,7 @@ class SpanPalette:
# self.lowBright.items())
#python 3.9+ only
self.colorMap = self.normalBright.items() | self.highBright.items() | self.lowBright.items()
self.colorMap = self.normalBright | self.highBright | self.lowBright
self.brightMap = {self.NORMAL_BRIGHT: {},
self.HIGH_BRIGHT: self.mapHighNormal,
self.LOW_BRIGHT: self.mapLowNormal}
@ -326,6 +326,9 @@ class SpanPalette:
"""
if not color:
return self.defaultColor[bright]
print("DEBUGG")
print(self.colorMap)
print(type(self.colorMap))
color = self.brightTransform(color, bright)
return self.colorMap.get(color, color)

@ -285,7 +285,7 @@ class process(StdoutableProcess):
else:
for line in self.readByLine():
pass
return self.cacheresult
return str(self.cacheresult, "UTF-8")
except KeyboardInterrupt:
self.kill()
raise KeyboardInterrupt
@ -802,7 +802,7 @@ def readLinesFile(filename, grab=False):
"""Read file by line"""
try:
if path.exists(filename):
for line in open(filename, 'r'):
for line in open(filename, 'r', encoding='utf-8'):
if grab:
line = line.strip()
if not line.startswith("#"):
@ -835,7 +835,7 @@ def readFile(filename):
"""
try:
if path.exists(filename):
with open(filename, 'r') as f:
with open(filename, 'r', encoding='utf-8') as f:
return f.read()
except (OSError, IOError) as e:
mod, lno = tools.get_traceback_caller(*sys.exc_info())
@ -853,7 +853,7 @@ def readFileEx(filename, tailbyte=None, headbyte=None, grab=False):
"""
try:
if path.exists(filename):
with open(filename, 'r') as f:
with open(filename, 'r', encoding='utf-8') as f:
if grab:
filterfunc = lambda s: "\n".join(
x for x in s.split("\n")
@ -883,7 +883,7 @@ def writeFile(filename):
dn = path.dirname(filename)
if not path.exists(dn):
os.makedirs(dn)
return open(filename, 'w')
return open(filename, 'w', encoding='utf-8')
class GetProgPath(object):
@ -1538,7 +1538,7 @@ def sha256sum(*fns):
kb = 1024
hasher = sha256()
for fn in fns:
with open(fn) as f:
with open(fn, encoding='utf-8') as f:
b = True
while b:
b = f.read(512 * kb)
@ -1698,7 +1698,7 @@ def checkDigestFile(digestfile):
hashobj = getattr(hashlib, alg.lower())
filename = path.join(path.dirname(digestfile), filename)
if os.path.exists(filename):
with open(filename, 'r') as f:
with open(filename, 'r', encoding='utf-8') as f:
digest = hashobj(f.read())
result.append((alg,
digest.hexdigest().upper() == hashdata.upper()))

@ -25,9 +25,11 @@ from calculate.lib.cl_lang import setLocalTranslate
_ = lambda x: x
setLocalTranslate('cl_lib3', sys.modules[__name__])
_u = lambda t: t.decode('UTF-8', 'replace') if isinstance(t, str) else t
# _u = lambda t: t.decode('UTF-8', 'replace') if isinstance(t, str) else t
_u = lambda t: t if isinstance(t, str) else t
_uu = lambda *tt: tuple(_u(t) for t in tt)
_u8 = lambda t: t.encode('UTF-8', 'replace') if isinstance(t, str) else t
# _u8 = lambda t: t.encode('UTF-8', 'replace') if isinstance(t, str) else t
_u8 = lambda t: t if isinstance(t, str) else t
_uu8 = lambda *tt: tuple(_u8(t) for t in tt)

@ -25,6 +25,7 @@ import sys
import os
import fcntl
from os import path
import errno
import time
from abc import ABCMeta, abstractmethod
from types import GeneratorType
@ -307,12 +308,12 @@ class Locker(object):
fcntl.flock(self.lockf, fcntl.LOCK_EX | fcntl.LOCK_NB)
return True
except IOError as e:
if e.errno != os.errno.EAGAIN:
if e.errno != errno.EAGAIN:
raise e
os.close(self.lockf)
self.lockf = None
except OSError as e:
if e.errno != os.errno.EEXIST:
if e.errno != errno.EEXIST:
raise e
time.sleep(0.25)
else:

Loading…
Cancel
Save