mirror of
https://github.com/platformio/platformio-core.git
synced 2025-08-01 02:54:25 +02:00
Fix issue with data decoding when calling PIO Core via PIO Home
This commit is contained in:
@@ -27,7 +27,13 @@ from twisted.internet import utils # pylint: disable=import-error
|
|||||||
|
|
||||||
from platformio import __main__, __version__, fs
|
from platformio import __main__, __version__, fs
|
||||||
from platformio.commands.home import helpers
|
from platformio.commands.home import helpers
|
||||||
from platformio.compat import PY2, get_filesystem_encoding, is_bytes, string_types
|
from platformio.compat import (
|
||||||
|
PY2,
|
||||||
|
get_filesystem_encoding,
|
||||||
|
get_locale_encoding,
|
||||||
|
is_bytes,
|
||||||
|
string_types,
|
||||||
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from thread import get_ident as thread_get_ident
|
from thread import get_ident as thread_get_ident
|
||||||
@@ -144,13 +150,15 @@ class PIOCoreRPC(object):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def _process_result(result, to_json=False):
|
def _process_result(result, to_json=False):
|
||||||
out, err, code = result
|
out, err, code = result
|
||||||
|
if out and is_bytes(out):
|
||||||
|
out = out.decode(get_locale_encoding())
|
||||||
|
if err and is_bytes(err):
|
||||||
|
err = err.decode(get_locale_encoding())
|
||||||
text = ("%s\n\n%s" % (out, err)).strip()
|
text = ("%s\n\n%s" % (out, err)).strip()
|
||||||
if code != 0:
|
if code != 0:
|
||||||
raise Exception(text)
|
raise Exception(text)
|
||||||
if not to_json:
|
if not to_json:
|
||||||
return text
|
return text
|
||||||
if is_bytes(out):
|
|
||||||
out = out.decode()
|
|
||||||
try:
|
try:
|
||||||
return json.loads(out)
|
return json.loads(out)
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
|
Reference in New Issue
Block a user