mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-30 01:57:13 +02:00
Fixed an issue with broken internal call for PIO Account // Resolve #2748
This commit is contained in:
2
docs
2
docs
Submodule docs updated: 49a86db3aa...8a81324c36
@ -22,8 +22,10 @@ from io import BytesIO, StringIO
|
|||||||
import click
|
import click
|
||||||
import jsonrpc # pylint: disable=import-error
|
import jsonrpc # pylint: disable=import-error
|
||||||
from twisted.internet import threads # pylint: disable=import-error
|
from twisted.internet import threads # pylint: disable=import-error
|
||||||
|
from twisted.internet import utils # pylint: disable=import-error
|
||||||
|
|
||||||
from platformio import __main__, __version__, util
|
from platformio import __main__, __version__, util
|
||||||
|
from platformio.commands.home import helpers
|
||||||
from platformio.compat import (PY2, get_filesystem_encoding, is_bytes,
|
from platformio.compat import (PY2, get_filesystem_encoding, is_bytes,
|
||||||
string_types)
|
string_types)
|
||||||
|
|
||||||
@ -78,6 +80,7 @@ class PIOCoreRPC(object):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def call(args, options=None):
|
def call(args, options=None):
|
||||||
PIOCoreRPC.setup_multithreading_std_streams()
|
PIOCoreRPC.setup_multithreading_std_streams()
|
||||||
|
cwd = (options or {}).get("cwd") or os.getcwd()
|
||||||
for i, arg in enumerate(args):
|
for i, arg in enumerate(args):
|
||||||
if isinstance(arg, string_types):
|
if isinstance(arg, string_types):
|
||||||
args[i] = arg.encode(get_filesystem_encoding()) if PY2 else arg
|
args[i] = arg.encode(get_filesystem_encoding()) if PY2 else arg
|
||||||
@ -85,12 +88,21 @@ class PIOCoreRPC(object):
|
|||||||
args[i] = str(arg)
|
args[i] = str(arg)
|
||||||
|
|
||||||
def _call_inline():
|
def _call_inline():
|
||||||
with util.cd((options or {}).get("cwd") or os.getcwd()):
|
with util.cd(cwd):
|
||||||
exit_code = __main__.main(["-c"] + args)
|
exit_code = __main__.main(["-c"] + args)
|
||||||
return (PIOCoreRPC.thread_stdout.get_value_and_reset(),
|
return (PIOCoreRPC.thread_stdout.get_value_and_reset(),
|
||||||
PIOCoreRPC.thread_stderr.get_value_and_reset(), exit_code)
|
PIOCoreRPC.thread_stderr.get_value_and_reset(), exit_code)
|
||||||
|
|
||||||
d = threads.deferToThread(_call_inline)
|
if args and args[0] in ("account", "remote"):
|
||||||
|
d = utils.getProcessOutputAndValue(
|
||||||
|
helpers.get_core_fullpath(),
|
||||||
|
args,
|
||||||
|
path=cwd,
|
||||||
|
env={k: v
|
||||||
|
for k, v in os.environ.items() if "%" not in k})
|
||||||
|
else:
|
||||||
|
d = threads.deferToThread(_call_inline)
|
||||||
|
|
||||||
d.addCallback(PIOCoreRPC._call_callback, "--json-output" in args)
|
d.addCallback(PIOCoreRPC._call_callback, "--json-output" in args)
|
||||||
d.addErrback(PIOCoreRPC._call_errback)
|
d.addErrback(PIOCoreRPC._call_errback)
|
||||||
return d
|
return d
|
||||||
|
@ -139,8 +139,9 @@ def pioplus_call(args, **kwargs):
|
|||||||
os.environ['PYTHONEXEPATH'] = pythonexe_path
|
os.environ['PYTHONEXEPATH'] = pythonexe_path
|
||||||
os.environ['PYTHONPYSITEDIR'] = get_core_package_dir("contrib-pysite")
|
os.environ['PYTHONPYSITEDIR'] = get_core_package_dir("contrib-pysite")
|
||||||
os.environ['PIOCOREPYSITEDIR'] = dirname(util.get_source_dir() or "")
|
os.environ['PIOCOREPYSITEDIR'] = dirname(util.get_source_dir() or "")
|
||||||
os.environ['PATH'] = (os.pathsep).join(
|
if dirname(pythonexe_path) not in os.environ['PATH'].split(os.pathsep):
|
||||||
[dirname(pythonexe_path), os.environ['PATH']])
|
os.environ['PATH'] = (os.pathsep).join(
|
||||||
|
[dirname(pythonexe_path), os.environ['PATH']])
|
||||||
copy_pythonpath_to_osenv()
|
copy_pythonpath_to_osenv()
|
||||||
code = subprocess.call([pioplus_path] + args, **kwargs)
|
code = subprocess.call([pioplus_path] + args, **kwargs)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user