|
|
|
@ -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()))
|
|
|
|
|