Encoding problems with dumping into json
@@ -6,12 +6,21 @@ import pip
import os
import base58
import subprocess
+import locale
+import codecs
from dateutil import parser
from ledger.genesis_txn.genesis_txn_file_util import genesis_txn_path
from stp_core.common.constants import ZMQ_NETWORK_PROTOCOL
from stp_core.common.log import getlogger
+
+def decode_err_handler(error):
+ length = error.end - error.start
+ return length * ' ', error.end
+
+codecs.register_error('decode_errors', decode_err_handler)
+
logger = getlogger()
MBs = 1024 * 1024
@@ -490,11 +499,10 @@ class ValidatorNodeInfoTool:
def _run_external_cmd(self, cmd):
ret = subprocess.run(cmd,
shell=True,
- universal_newlines=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
timeout=5)
- return ret.stdout
+ return ret.stdout.decode(locale.getpreferredencoding(), 'decode_errors')
def _get_journalctl_exceptions(self):
output = self._run_external_cmd("journalctl | sed -n '/Traceback/,/Error/p'")
