Skip to content

Commit

Permalink
Merge pull request #2575 from theotherjimmy/allow-empty-config
Browse files Browse the repository at this point in the history
tools-config! -  Allow an empty or mal-formed config to be passed to the config system
  • Loading branch information
sg- authored Sep 9, 2016
2 parents 72b0d46 + c7bf3fa commit 2c96001
Showing 1 changed file with 15 additions and 4 deletions.
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

0 comments on commit 2c96001

Please sign in to comment.