From d4f1d88e0aebb6282aaa8038d0910482be416304 Mon Sep 17 00:00:00 2001 From: Sergei Silnov Date: Mon, 30 May 2022 19:27:54 +0200 Subject: [PATCH] Print suggestion to update the component manager on manifest errors --- CHANGELOG.md | 4 ++++ idf_component_tools/manifest/manager.py | 17 +++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f70a0a1..4b4dec1c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- Print suggestion to update the component manager on manifest errors + ### Fixed - Fix expansion of environment variables in manifest for `rules` diff --git a/idf_component_tools/manifest/manager.py b/idf_component_tools/manifest/manager.py index 778e6dd5..f2071aaf 100644 --- a/idf_component_tools/manifest/manager.py +++ b/idf_component_tools/manifest/manager.py @@ -1,4 +1,5 @@ import os +import sys from io import open import yaml @@ -16,6 +17,12 @@ EMPTY_MANIFEST = dict() # type: Dict[str, Any] +UPDATE_SUGGESTION = """ +SUGGESTION: This component may be using a newer version of the component manager. +You can try to update the component manager by running: + {} -m pip install --upgrade idf-component-manager +""".format(sys.executable) + class ManifestManager(object): """Parser for manifest files in the project""" @@ -108,11 +115,13 @@ def load(self): # type: () -> Manifest if not self.is_valid: error_count = len(self.validation_errors) if error_count == 1: - error_desc = ['A problem was found in the manifest file %s:' % self._path] + self.validation_errors + error_desc = ['A problem was found in the manifest file %s:' % self._path] else: - error_desc = [ - '%i problems were found in the manifest file %s:' % (error_count, self._path) - ] + self.validation_errors + error_desc = ['%i problems were found in the manifest file %s:' % (error_count, self._path)] + + error_desc.extend(self.validation_errors) + + error_desc.append(UPDATE_SUGGESTION) raise ManifestError('\n'.join(error_desc))