From b165c3f543533094d65544f3bc59d4f4642abc83 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 11 Jul 2016 22:40:37 +0300 Subject: [PATCH] Ignore "[platformio]" section from custom project configuration CI --- HISTORY.rst | 3 +++ platformio/__init__.py | 2 +- platformio/commands/ci.py | 17 ++++++++++++++++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index c9629b4d..1e644f1d 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -15,6 +15,9 @@ PlatformIO 2.0 * Improved project generator for `CLion IDE `__ * Auto-remove project cache when PlatformIO is upgraded * Keep user changes for ``.gitignore`` file when re-generate/update project data +* Ignore ``[platformio]`` section from custom project configuration file when + `platformio ci --project-conf `__ + command is used * Fixed missed ``--boot`` flag for the firmware uploader for ATSAM3X8E Cortex-M3 MCU based boards (Arduino Due, etc) (`issue #710 `_) diff --git a/platformio/__init__.py b/platformio/__init__.py index 3c27dd05..1bf8e37c 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (2, 11, "1b1") +VERSION = (2, 11, "1b2") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/commands/ci.py b/platformio/commands/ci.py index 602ef67d..bb503e40 100644 --- a/platformio/commands/ci.py +++ b/platformio/commands/ci.py @@ -27,6 +27,12 @@ from platformio.commands.run import cli as cmd_run from platformio.exception import CIBuildEnvsEmpty from platformio.util import get_boards +# pylint: disable=wrong-import-order +try: + from configparser import ConfigParser +except ImportError: + from ConfigParser import ConfigParser + def validate_path(ctx, param, value): # pylint: disable=W0613 invalid_path = None @@ -91,7 +97,7 @@ def cli(ctx, src, lib, exclude, board, # pylint: disable=R0913 _copy_contents(join(build_dir, dir_name), contents) if project_conf and isfile(project_conf): - copyfile(project_conf, join(build_dir, "platformio.ini")) + _copy_project_conf(build_dir, project_conf) elif not board: raise CIBuildEnvsEmpty() @@ -157,3 +163,12 @@ def _exclude_contents(dst_dir, patterns): rmtree(path) elif isfile(path): remove(path) + + +def _copy_project_conf(build_dir, project_conf): + cp = ConfigParser() + cp.read(project_conf) + if cp.has_section("platformio"): + cp.remove_section("platformio") + with open(join(build_dir, "platformio.ini"), "w") as fp: + cp.write(fp)