def load_project_config(project_dir=None): if not project_dir: project_dir = get_project_dir() if not is_platformio_project(project_dir): raise exception.NotPlatformIOProject(project_dir) cp = ConfigParser() cp.read(join(project_dir, "platformio.ini")) return cp
def load_project_config(path=None): if not path or isdir(path): path = join(path or get_project_dir(), "platformio.ini") if not isfile(path): raise exception.NotPlatformIOProject( dirname(path) if path.endswith("platformio.ini") else path) cp = ProjectConfig() cp.read(path) return cp
def load_project_config(path=None): if not path or isdir(path): project_dir = path or get_project_dir() if not is_platformio_project(project_dir): raise exception.NotPlatformIOProject(project_dir) path = join(project_dir, "platformio.ini") assert isfile(path) cp = ProjectConfig() cp.read(path) return cp
def load_project_config(path=None): if not path or isdir(path): path = join(path or get_project_dir(), "platformio.ini") if not isfile(path): raise exception.NotPlatformIOProject( dirname(path) if path.endswith("platformio.ini") else path) cp = ProjectConfig() try: cp.read(path) except ConfigParser.Error as e: raise exception.InvalidProjectConf(str(e)) return cp
def validate(self, envs=None, silent=False): if not os.path.isfile(self.path): raise exception.NotPlatformIOProject(self.path) # check envs known = set(self.envs()) if not known: raise exception.ProjectEnvsNotAvailable() unknown = set(list(envs or []) + self.default_envs()) - known if unknown: raise exception.UnknownEnvNames(", ".join(unknown), ", ".join(known)) if not silent: for warning in self.warnings: click.secho("Warning! %s" % warning, fg="yellow") return True
def cli(ctx, environment, target, upload_port, project_dir, silent, verbose, disable_auto_clean): # find project directory on upper level if isfile(project_dir): project_dir = util.find_project_dir_above(project_dir) if not util.is_platformio_project(project_dir): raise exception.NotPlatformIOProject(project_dir) with util.cd(project_dir): # clean obsolete .pioenvs dir if not disable_auto_clean: try: _clean_pioenvs_dir(util.get_projectpioenvs_dir()) except: # pylint: disable=bare-except click.secho( "Can not remove temporary directory `%s`. Please remove " "`.pioenvs` directory from the project manually to avoid " "build issues" % util.get_projectpioenvs_dir(force=True), fg="yellow") config = util.load_project_config() check_project_defopts(config) assert check_project_envs(config, environment) env_default = None if config.has_option("platformio", "env_default"): env_default = [ e.strip() for e in config.get("platformio", "env_default").split(", ") ] results = [] start_time = time() for section in config.sections(): if not section.startswith("env:"): continue envname = section[4:] skipenv = any([ environment and envname not in environment, not environment and env_default and envname not in env_default ]) if skipenv: results.append((envname, None)) continue if not silent and results: click.echo() options = {} for k, v in config.items(section): options[k] = v if "piotest" not in options and "piotest" in ctx.meta: options['piotest'] = ctx.meta['piotest'] ep = EnvironmentProcessor(ctx, envname, options, target, upload_port, silent, verbose) result = (envname, ep.process()) results.append(result) if result[1] and "monitor" in ep.get_build_targets() and \ "nobuild" not in ep.get_build_targets(): ctx.invoke(cmd_device_monitor) found_error = any([status is False for (_, status) in results]) if (found_error or not silent) and len(results) > 1: click.echo() print_summary(results, start_time) if found_error: raise exception.ReturnErrorCode(1) return True
def cli(ctx, environment, target, upload_port, project_dir, silent, verbose, disable_auto_clean): # find project directory on upper level if isfile(project_dir): project_dir = util.find_project_dir_above(project_dir) if not util.is_platformio_project(project_dir): raise exception.NotPlatformIOProject(project_dir) with util.cd(project_dir): # clean obsolete .pioenvs dir if not disable_auto_clean: try: _clean_pioenvs_dir(util.get_projectpioenvs_dir()) except: # pylint: disable=bare-except click.secho( "Can not remove temporary directory `%s`. Please remove " "`.pioenvs` directory from the project manually to avoid " "build issues" % util.get_projectpioenvs_dir(force=True), fg="yellow") config = util.load_project_config() check_project_defopts(config) assert check_project_envs(config, environment) env_default = None if config.has_option("platformio", "env_default"): env_default = [ e.strip() for e in config.get("platformio", "env_default").split(",") ] results = [] for section in config.sections(): # skip main configuration section if section == "platformio": continue if not section.startswith("env:"): raise exception.InvalidEnvName(section) envname = section[4:] skipenv = any([ environment and envname not in environment, not environment and env_default and envname not in env_default ]) if skipenv: # echo("Skipped %s environment" % style(envname, fg="yellow")) continue if results: click.echo() options = {} for k, v in config.items(section): options[k] = v if "piotest" not in options and "piotest" in ctx.meta: options['piotest'] = ctx.meta['piotest'] ep = EnvironmentProcessor(ctx, envname, options, target, upload_port, silent, verbose) results.append(ep.process()) if not all(results): raise exception.ReturnErrorCode() return True
def cli(ctx, environment, target, upload_port, project_dir, silent, verbose, disable_auto_clean): # find project directory on upper level if isfile(project_dir): project_dir = util.find_project_dir_above(project_dir) if not util.is_platformio_project(project_dir): raise exception.NotPlatformIOProject(project_dir) with util.cd(project_dir): # clean obsolete .pioenvs dir if not disable_auto_clean: try: _clean_pioenvs_dir(util.get_projectpioenvs_dir()) except: # pylint: disable=bare-except click.secho( "Can not remove temporary directory `%s`. Please remove " "`.pioenvs` directory from the project manually to avoid " "build issues" % util.get_projectpioenvs_dir(force=True), fg="yellow") config = util.load_project_config() check_project_defopts(config) assert check_project_envs(config, environment) env_default = None if config.has_option("platformio", "env_default"): env_default = [ e.strip() for e in config.get("platformio", "env_default").split(",") ] results = {} start_time = time() for section in config.sections(): if not section.startswith("env:"): continue envname = section[4:] skipenv = any([ environment and envname not in environment, not environment and env_default and envname not in env_default ]) if skipenv: results[envname] = None continue if results: click.echo() options = {} for k, v in config.items(section): options[k] = v if "piotest" not in options and "piotest" in ctx.meta: options['piotest'] = ctx.meta['piotest'] ep = EnvironmentProcessor(ctx, envname, options, target, upload_port, silent, verbose) results[envname] = ep.process() if len(results) > 1: click.echo() print_header("[%s]" % click.style("SUMMARY")) successed = True for envname, status in results.items(): status_str = click.style("SUCCESS", fg="green") if status is False: successed = False status_str = click.style("ERROR", fg="red") elif status is None: status_str = click.style("SKIP", fg="yellow") click.echo("Environment %s\t[%s]" % (click.style(envname, fg="cyan"), status_str), err=status is False) print_header( "[%s] Took %.2f seconds" % ((click.style("SUCCESS", fg="green", bold=True) if successed else click.style("ERROR", fg="red", bold=True)), time() - start_time), is_error=not successed) if any([r is False for r in results.values()]): raise exception.ReturnErrorCode() return True