mirror of https://github.com/tLDP/python-tldp
switch to codecs.open and expect UTF-8 data
This commit is contained in:
parent
2afbc7a147
commit
dcb8b3a217
|
@ -7,6 +7,7 @@ import os
|
||||||
import sys
|
import sys
|
||||||
import stat
|
import stat
|
||||||
import errno
|
import errno
|
||||||
|
import codecs
|
||||||
import shutil
|
import shutil
|
||||||
import logging
|
import logging
|
||||||
import inspect
|
import inspect
|
||||||
|
@ -202,12 +203,13 @@ class BaseDoctype(object):
|
||||||
|
|
||||||
s = script.format(output=output, source=source, config=config)
|
s = script.format(output=output, source=source, config=config)
|
||||||
tf = ntf(dir=logdir, prefix=prefix, suffix='.sh', delete=False)
|
tf = ntf(dir=logdir, prefix=prefix, suffix='.sh', delete=False)
|
||||||
if preamble:
|
|
||||||
tf.write(preamble)
|
|
||||||
tf.write(s)
|
|
||||||
if postamble:
|
|
||||||
tf.write(postamble)
|
|
||||||
tf.close()
|
tf.close()
|
||||||
|
with codecs.open(tf.name, 'w', encoding='utf-8') as f:
|
||||||
|
if preamble:
|
||||||
|
f.write(preamble)
|
||||||
|
f.write(s)
|
||||||
|
if postamble:
|
||||||
|
f.write(postamble)
|
||||||
|
|
||||||
mode = stat.S_IXUSR | stat.S_IRUSR | stat.S_IWUSR
|
mode = stat.S_IXUSR | stat.S_IRUSR | stat.S_IWUSR
|
||||||
os.chmod(tf.name, mode)
|
os.chmod(tf.name, mode)
|
||||||
|
@ -215,7 +217,7 @@ class BaseDoctype(object):
|
||||||
cmd = [tf.name]
|
cmd = [tf.name]
|
||||||
result = execute(cmd, logdir=logdir)
|
result = execute(cmd, logdir=logdir)
|
||||||
if result != 0:
|
if result != 0:
|
||||||
with open(tf.name) as f:
|
with codecs.open(tf.name, encoding='utf-8') as f:
|
||||||
for line in f:
|
for line in f:
|
||||||
logger.info("Script: %s", line.rstrip())
|
logger.info("Script: %s", line.rstrip())
|
||||||
return False
|
return False
|
||||||
|
|
Loading…
Reference in New Issue