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
|
return reply_value
|
||||||
|
|
||||||
def prepare_write(self, key, new_value):
|
def prepare_write(self, key, new_value):
|
||||||
choices = self.choices[key]
|
choices = self.choices.get(key)
|
||||||
if new_value not in choices and new_value != self.extra_default:
|
if choices is None or (new_value not in choices and new_value != self.extra_default):
|
||||||
raise ValueError('invalid choice %r' % new_value)
|
_log.error('invalid choice %r for %s', new_value, key)
|
||||||
|
return None
|
||||||
new_value = new_value | self.activate
|
new_value = new_value | self.activate
|
||||||
return self._write_prefix_bytes + new_value.to_bytes(self._byte_count, 'big')
|
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):
|
def _feature_divert_keys_callback(device):
|
||||||
choices = {}
|
choices = {}
|
||||||
for k in device.keys:
|
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')]
|
choices[k.key] = [_NamedInt(0x00, 'Regular'), _NamedInt(0x01, 'Diverted')]
|
||||||
if not choices:
|
if not choices:
|
||||||
return None
|
return None
|
||||||
|
|
Loading…
Reference in New Issue