Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools-config! - Allow an empty or mal-formed config to be passed to the config system #2575

Merged
merged 1 commit into from
Sep 9, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions tools/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@
limitations under the License.
"""

import os
import sys

# Implementation of mbed configuration mechanism
from tools.utils import json_file_to_dict
from tools.targets import Target
import os

# Base class for all configuration exceptions
class ConfigException(Exception):
Expand Down Expand Up @@ -376,8 +378,12 @@ def __init__(self, target, top_level_dirs=None):
app_config_location, full_path))
else:
app_config_location = full_path
self.app_config_data = json_file_to_dict(app_config_location) \
if app_config_location else {}
try:
self.app_config_data = json_file_to_dict(app_config_location) \
if app_config_location else {}
except ValueError as exc:
sys.stderr.write(str(exc) + "\n")
self.app_config_data = {}
# Check the keys in the application configuration data
unknown_keys = set(self.app_config_data.keys()) - \
self.__allowed_keys["application"]
Expand Down Expand Up @@ -419,7 +425,12 @@ def add_config_files(self, flist):
self.processed_configs[full_path] = True
# Read the library configuration and add a "__full_config_path"
# attribute to it
cfg = json_file_to_dict(config_file)
try:
cfg = json_file_to_dict(config_file)
except ValueError as exc:
sys.stderr.write(str(exc) + "\n")
continue

cfg["__config_path"] = full_path

if "name" not in cfg:
Expand Down