From 89e8089e1cd70ff30347e094ee4259bc182a37df Mon Sep 17 00:00:00 2001 From: Mike Date: Mon, 15 Mar 2021 11:36:44 +0000 Subject: [PATCH] Fix handling of `HWCONFIG_OPTS` (#2267) --- Sming/Components/Storage/Tools/hwconfig/config.py | 15 ++++++++------- .../Storage/Tools/hwconfig/partition.py | 1 - 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Sming/Components/Storage/Tools/hwconfig/config.py b/Sming/Components/Storage/Tools/hwconfig/config.py index a3e1584a15..19bad09f79 100644 --- a/Sming/Components/Storage/Tools/hwconfig/config.py +++ b/Sming/Components/Storage/Tools/hwconfig/config.py @@ -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 @@ -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) @@ -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) diff --git a/Sming/Components/Storage/Tools/hwconfig/partition.py b/Sming/Components/Storage/Tools/hwconfig/partition.py index d5e98ba495..d0a0e07f1e 100644 --- a/Sming/Components/Storage/Tools/hwconfig/partition.py +++ b/Sming/Components/Storage/Tools/hwconfig/partition.py @@ -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())