Skip to content

Commit

Permalink
Fix handling of HWCONFIG_OPTS (#2267)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikee47 authored Mar 15, 2021
1 parent bae6f11 commit 89e8089
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
15 changes: 8 additions & 7 deletions Sming/Components/Storage/Tools/hwconfig/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,20 @@ def from_name(cls, name):
"""
config = Config()
options = os.environ.get('HWCONFIG_OPTS', '').replace(' ', '')
config.load(name, [] if options == '' else options.split(','))
config.load(name)
if options != '':
config.parse_options(options.split(','))
config.partitions.sort()
return config

def load(self, name, options=[]):
def load(self, name):
"""Load a configuration recursively
"""
filename = findConfig(name)
self.depends.append(filename)
with open(filename) as f:
data = json.loads(jsmin(f.read()))
self.parse_dict(data, options)
self.parse_dict(data)

def parse_options(self, options):
"""Apply any specified options, each option is applied only once
Expand All @@ -70,12 +73,12 @@ def parse_options(self, options):
temp.pop('description', None)
self.parse_dict(temp)

def parse_dict(self, data, options = []):
def parse_dict(self, data):
base_config = data.pop('base_config', None)
if base_config is not None:
self.load(base_config)

self.parse_options(options)
self.parse_options(data.pop('options', []))

# We'll process partitions after other settings
partitions = data.pop('partitions', None)
Expand All @@ -91,8 +94,6 @@ def parse_dict(self, data, options = []):
self.devices.parse_dict(v)
elif k == 'comment':
self.comment = v
elif k == 'options':
self.parse_options(v)
else:
raise InputError("Unknown config key '%s'" % k)

Expand Down
1 change: 0 additions & 1 deletion Sming/Components/Storage/Tools/hwconfig/partition.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ def parse_dict(self, data, devices):
part = Entry(devices[0], name)
self.append(part)
part.parse_dict(entry, devices)
self.sort()

def sort(self):
super(Table, self).sort(key=lambda p: p.device.name + p.address_str())
Expand Down

0 comments on commit 89e8089

Please sign in to comment.