settings: don't halt when trying to write invalid map choice
This commit is contained in:
parent
75fec689a0
commit
7add22e861
|
@ -925,9 +925,10 @@ class ChoicesMapValidator(ChoicesValidator):
|
|||
return reply_value
|
||||
|
||||
def prepare_write(self, key, new_value):
|
||||
choices = self.choices[key]
|
||||
if new_value not in choices and new_value != self.extra_default:
|
||||
raise ValueError('invalid choice %r' % new_value)
|
||||
choices = self.choices.get(key)
|
||||
if choices is None or (new_value not in choices and new_value != self.extra_default):
|
||||
_log.error('invalid choice %r for %s', new_value, key)
|
||||
return None
|
||||
new_value = new_value | self.activate
|
||||
return self._write_prefix_bytes + new_value.to_bytes(self._byte_count, 'big')
|
||||
|
||||
|
|
|
@ -646,7 +646,7 @@ class DivertKeysRW(object):
|
|||
def _feature_divert_keys_callback(device):
|
||||
choices = {}
|
||||
for k in device.keys:
|
||||
if 'divertable' in k.flags:
|
||||
if 'divertable' in k.flags and 'virtual' not in k.flags:
|
||||
choices[k.key] = [_NamedInt(0x00, 'Regular'), _NamedInt(0x01, 'Diverted')]
|
||||
if not choices:
|
||||
return None
|
||||
|
|
Loading…
Reference in New Issue