mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-31 18:44:27 +02:00
Cleanup code
This commit is contained in:
@@ -37,7 +37,8 @@ class PlatformioCLI(click.MultiCommand): # pylint: disable=R0904
|
|||||||
raise exception.UnknownCLICommand(name)
|
raise exception.UnknownCLICommand(name)
|
||||||
return mod.cli
|
return mod.cli
|
||||||
|
|
||||||
def _handle_obsolate_command(self, name):
|
@staticmethod
|
||||||
|
def _handle_obsolate_command(name):
|
||||||
if name in ("install", "list", "search", "show", "uninstall"):
|
if name in ("install", "list", "search", "show", "uninstall"):
|
||||||
click.secho(
|
click.secho(
|
||||||
"Warning! `platformio %s` command is obsoleted and will be "
|
"Warning! `platformio %s` command is obsoleted and will be "
|
||||||
|
@@ -45,39 +45,42 @@ def cli(ctx, environment, target, upload_port, project_dir):
|
|||||||
getmtime(_pioenvs_dir)):
|
getmtime(_pioenvs_dir)):
|
||||||
rmtree(_pioenvs_dir)
|
rmtree(_pioenvs_dir)
|
||||||
|
|
||||||
found_error = False
|
results = []
|
||||||
_first_done = False
|
|
||||||
for section in config.sections():
|
for section in config.sections():
|
||||||
# skip main configuration section
|
if results and results[-1] is not None:
|
||||||
if section == "platformio":
|
|
||||||
continue
|
|
||||||
elif section[:4] != "env:":
|
|
||||||
raise exception.InvalidEnvName(section)
|
|
||||||
|
|
||||||
envname = section[4:]
|
|
||||||
if environment and envname not in environment:
|
|
||||||
# echo("Skipped %s environment" % style(envname, fg="yellow"))
|
|
||||||
continue
|
|
||||||
|
|
||||||
options = {}
|
|
||||||
for k, v in config.items(section):
|
|
||||||
options[k] = v
|
|
||||||
|
|
||||||
if _first_done:
|
|
||||||
click.echo()
|
click.echo()
|
||||||
|
|
||||||
if not process_environment(
|
results.append(_process_conf_section(
|
||||||
ctx, envname, options, target, upload_port):
|
ctx, config, section, environment, target, upload_port))
|
||||||
found_error = True
|
|
||||||
_first_done = True
|
|
||||||
|
|
||||||
if found_error:
|
if not all([r for r in results if r is not None]):
|
||||||
raise exception.ReturnErrorCode()
|
raise exception.ReturnErrorCode()
|
||||||
finally:
|
finally:
|
||||||
chdir(initial_cwd)
|
chdir(initial_cwd)
|
||||||
|
|
||||||
|
|
||||||
def process_environment(ctx, name, options, targets, upload_port):
|
def _process_conf_section(ctx, config, section, # pylint: disable=R0913
|
||||||
|
environment, target, upload_port):
|
||||||
|
# skip main configuration section
|
||||||
|
if section == "platformio":
|
||||||
|
return None
|
||||||
|
|
||||||
|
if section[:4] != "env:":
|
||||||
|
raise exception.InvalidEnvName(section)
|
||||||
|
|
||||||
|
envname = section[4:]
|
||||||
|
if environment and envname not in environment:
|
||||||
|
# echo("Skipped %s environment" % style(envname, fg="yellow"))
|
||||||
|
return None
|
||||||
|
|
||||||
|
options = {}
|
||||||
|
for k, v in config.items(section):
|
||||||
|
options[k] = v
|
||||||
|
|
||||||
|
return _process_environment(ctx, envname, options, target, upload_port)
|
||||||
|
|
||||||
|
|
||||||
|
def _process_environment(ctx, name, options, targets, upload_port):
|
||||||
terminal_width, _ = click.get_terminal_size()
|
terminal_width, _ = click.get_terminal_size()
|
||||||
start_time = time()
|
start_time = time()
|
||||||
|
|
||||||
|
@@ -19,7 +19,7 @@ from platformio.commands.platforms import \
|
|||||||
from platformio.commands.upgrade import get_latest_version
|
from platformio.commands.upgrade import get_latest_version
|
||||||
from platformio.libmanager import LibraryManager
|
from platformio.libmanager import LibraryManager
|
||||||
from platformio.platforms.base import PlatformFactory
|
from platformio.platforms.base import PlatformFactory
|
||||||
from platformio.util import get_home_dir, get_lib_dir
|
from platformio.util import get_home_dir
|
||||||
|
|
||||||
|
|
||||||
def on_platformio_start(ctx, force):
|
def on_platformio_start(ctx, force):
|
||||||
|
Reference in New Issue
Block a user