def goto_step(self, step_number): logging.debug('[Protocol].goto_step(%s)' % step_number) self.current_step_number = step_number original_step_number = self.current_step_number for plugin_name in self.current_step().plugins: emit_signal('on_step_options_swapped', [plugin_name, original_step_number, step_number], interface=IPlugin) with closing(StringIO()) as sio: for plugin_name, fields in self.plugin_fields.iteritems(): observers = ExtensionPoint(IPlugin) service = observers.service(plugin_name) if service is None: # We can end up here if a service has been disabled. # TODO: protocol.plugin_fields should likely be updated # whenever a plugin is enabled/disabled... continue if hasattr(service, 'get_step_value'): print >> sio, '[ProtocolController] plugin.name=%s field_values='\ % (plugin_name), print >> sio, [service.get_step_value(f) for f in fields] logging.debug(sio.getvalue()) emit_signal('on_step_swapped', [original_step_number, step_number])
def get_device_directory(self): observers = ExtensionPoint(IPlugin) plugin_name = 'microdrop.gui.dmf_device_controller' service = observers.service(plugin_name) values = service.get_app_values() if values and 'device_directory' in values: directory = path(values['device_directory']) if directory.isdir(): return directory return None
def _get_app_values(self, plugin_name): observers = ExtensionPoint(IPlugin) service = observers.service(plugin_name) if not hasattr(service, 'get_app_values'): values = dict([(k, v.value) for k,v in self.forms[plugin_name].from_defaults().iteritems()]) else: values = service.get_app_values() if not values: return {} else: return values
def apply(self): for name, form_view in self.form_views.iteritems(): fields = form_view.form.fields.keys() attrs = {} for field in fields: if form_view.form.fields[field].element.validate(): attrs[field] = form_view.form.fields[field].element.value else: logger.error('Failed to set %s value for %s' % (field, name)) if attrs: observers = ExtensionPoint(IPlugin) service = observers.service(name) service.set_app_values(attrs)
def get_plugin_step_values(plugin_name, step_number=None): observers = ExtensionPoint(IPlugin) service = observers.service(plugin_name) if hasattr(service, 'get_step_values'): return service.get_step_values(step_number) return None
def get_plugin_app_values(plugin_name): observers = ExtensionPoint(IPlugin) service = observers.service(plugin_name) if hasattr(service, 'get_app_values'): return service.get_app_values() return None