Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
state_name = self.failsafe_state.name
else:
raise
if state_name not in self.states:
raise ValueError('"{}" not in registered states...'.format(state_name))
# Switch to the new state and perform its entry actions
LOGGER.debug("Activate state '%s'", state_name)
self.active_state = self.states[state_name]
try:
self.active_state.entry_actions()
except Exception as ex:
if self.failsafe_state and self.active_state != self.failsafe_state:
LOGGER.error(str(ex))
if BlockConsoleHandler.is_debug():
traceback.print_exc()
self.set_state(self.failsafe_state.name)
else:
raise
LOGGER.debug('Setting option %s/%s=%s', section, option, value)
config = self._cam.get_config()
child = config.get_child_by_name(section).get_child_by_name(option)
if child.get_type() == gp.GP_WIDGET_RADIO:
choices = [c for c in child.get_choices()]
else:
choices = None
data_type = type(child.get_value())
value = data_type(value) # Cast value
if choices and value not in choices:
LOGGER.warning(
"Invalid value '%s' for option %s (possible choices: %s), trying to set it anyway", value, option, choices)
child.set_value(value)
self._cam.set_config(config)
except gp.GPhoto2Error as ex:
LOGGER.error('Unsupported option %s/%s=%s (%s), configure your DSLR manually', section, option, value, ex)