def initialize(self): super(BundledDistro, self).initialize() if LSB_INFO: for osplugin in PluginManager.get_plugins(IOSPlugin): if osplugin.is_valid(LSB_INFO) and osplugin.__class__ != self.__class__: self.__class__.__bases__ = (osplugin.__class__, ) return
def process_device_added(): properties = self.get_devices_properties() cached_id = None for device in DeviceProfileCache.get_cached_devices(): if device in properties: cached_id = device.cached_id for plugin in PluginManager.get_plugins(IDBusDevicePlugin): if plugin in properties: try: plugin.setup(properties) if cached_id: plugin.cached_id = cached_id if (plugin.udi in self.udi_device): continue self.udi_device[str(plugin.udi)] = plugin d = DeviceResolver.identify_device(plugin) def select_and_configure(name): try: plugin = \ PluginManager.get_plugin_by_remote_name(name) plugin.setup(properties) self.udi_device[str(plugin.udi)] = plugin self.device_list.append(plugin) self.view.device_added(plugin) except Exception, e: print e d.addCallback(select_and_configure) except Exception, e: pass
def get_groups(): for osplugin in PluginManager.get_plugins(IOSPlugin): try: if osplugin.os_name.match(os_info['os_name']): if osplugin.os_version: if osplugin.os_version.match(os_info['os_version']): log.msg('osplugin: %s' % (osplugin.__class__)) return osplugin.os_groups else: # Version doesn't match. pass else: # No version specified. log.msg('osplugin: %s' % (osplugin.__class__)) return osplugin.os_groups else: # Distro name doesn't match. pass except KeyError: pass # No matching os plugin found. message = 'OS/Distro not registered' details = """ The OS/Distro under which you are running %s is not registered in the OS database. Check the common.oal module for what you can do in order to support your OS/Distro """ % APP_LONG_NAME # dialogs.open_warning_dialog(message, details) log.msg('%s %s' % (message, details)) raise OSNotRegisteredError
def get_groups(): for osplugin in PluginManager.get_plugins(IOSPlugin): try: if osplugin.os_name.match(os_info["os_name"]): if osplugin.os_version: if osplugin.os_version.match(os_info["os_version"]): log.msg("osplugin: %s" % (osplugin.__class__)) return osplugin.os_groups else: # Version doesn't match. pass else: # No version specified. log.msg("osplugin: %s" % (osplugin.__class__)) return osplugin.os_groups else: # Distro name doesn't match. pass except KeyError: pass # No matching os plugin found. message = "OS/Distro not registered" details = ( """ The OS/Distro under which you are running %s is not registered in the OS database. Check the common.oal module for what you can do in order to support your OS/Distro """ % APP_LONG_NAME ) # dialogs.open_warning_dialog(message, details) log.msg("%s %s" % (message, details)) raise OSNotRegisteredError
def identify_device_cb(model): # plugin to return _plugin = None if plugin.mapping: if model in plugin.mapping: _plugin = plugin.mapping[model]() # the plugin has no mapping, chances are that we already identified # it by its vendor & product id elif plugin.__remote_name__ != model: from vmc.common.plugin import PluginManager # so we basically have a device identified by vendor & product id # but we know nuthin of this model try: _plugin = PluginManager.get_plugin_by_remote_name(model) except ex.UnknownPluginNameError: plugin.name = model if _plugin is not None: # we found another plugin during the process _plugin.patch(plugin) return _plugin else: return plugin
def process_device_added(self): from vmc.common.plugin import PluginManager properties = self.get_devices_properties() for plugin in PluginManager.get_plugins(IDBusDevicePlugin): if plugin in properties: plugin.setup(properties) louie.send(notifications.SIG_DEVICE_ADDED, None, plugin) self.device = plugin
def initialize(self): super(BundledDistro, self).initialize() if LSB_INFO: for osplugin in PluginManager.get_plugins(IOSPlugin): if osplugin.is_valid( LSB_INFO) and osplugin.__class__ != self.__class__: self.__class__.__bases__ = (osplugin.__class__, ) return
def __init__(self, wrapper, device, kwds): super(NotificationsManager, self).__init__() self.wrapper = wrapper self.queue = device.sconn.notifications self.listeners = [] self.plugin_listeners = [p for p in PluginManager.get_plugins( INotificationPlugin)] self.running = False self.signal_map = {} self.setup_signals(kwds)
def select_and_configure(name): try: plugin = \ PluginManager.get_plugin_by_remote_name(name) plugin.setup(properties) self.udi_device[str(plugin.udi)] = plugin self.device_list.append(plugin) self.view.device_added(plugin) except Exception, e: print e
def __init__(self, wrapper, device, kwds): super(NotificationsManager, self).__init__() from vmc.common.plugin import PluginManager self.wrapper = wrapper self.queue = device.sconn.notifications self.listeners = [] self.plugin_listeners = [p for p in PluginManager.get_plugins( INotificationPlugin)] self.running = False self.signal_map = {} self.setup_signals(kwds)
def get_plugin_from_name(self, name, dev): try: plugin = PluginManager.get_plugin_by_remote_name(name) plugin.dport = dev.dport plugin.baudrate = dev.baudrate if dev.cport: plugin.cport = dev.cport return plugin except UnknownPluginNameError, e: # we have a device that share's the ID with other plugin (potentially # based on the same chipset) but its remote name differs, this is # probably gonna be a new revision of a model, we will risk ourselves # and use the most similar plugin we know of return dev
def get_os_object(): """ Returns a C{BaseDistribution} object corresponding to current OS used @raise OSNotRegisteredError: If the OS is not supported. """ from vmc.common.plugin import PluginManager from vmc.common.interfaces import IOSPlugin for osplugin in PluginManager.get_plugins(IOSPlugin): if osplugin.is_valid(): osplugin.initialize() return osplugin raise OSNotRegisteredError
def _get_device_from_info_and_ports(self, info, udi, ports): """ Returns a C{DevicePlugin} out of C{info} and C{dport} and {cport} """ from vmc.common.plugin import PluginManager plugin = PluginManager.get_plugin_by_vendor_product_id(*info.values()) if plugin: # set its udi plugin.udi = udi if hasattr(plugin, 'preprobe_init'): # this plugin requires special initialisation before probing plugin.preprobe_init(ports, extract_info(info)) if hasattr(plugin, 'hardcoded_ports'): # this plugin registers its ports in a funky way and thus # the probe algorithm wont work for it. hardcoded_ports is # a tuple of size two that contains the indexes of the ports # that should be used for dport and cport. dport_index, cport_index = plugin.hardcoded_ports dport = ports[dport_index] try: if type(cport_index) == type(None): cport = None else: cport = ports[cport_index] except Exception, e: log.err() cport = None else: # probe ports dport, cport = probe_ports(ports) if not dport and not cport: # this shouldn't happen raise RuntimeError("No data port and no control port") print "data port is %s" % dport if cport: print "ctrl port is %s" % cport plugin.cport, plugin.dport = cport, dport return plugin
def _get_dbus_devices(self): """ Returns a list with all the IDBusDevicePlugin that might be present This list is potentially unaccurate as devices from the same company tend to share product_ids and you might get plugins that aren't present @raise DeviceLacksExtractInfo: If the device found lacks any of the necessary control/data ports. @raise DeviceNotFoundError: If no known device was found """ exceptions = [] found_plugins = [] device_properties = self.get_devices_properties() for plugin in PluginManager.get_plugins(IDBusDevicePlugin): # DBusDevicePlugin implements __eq__ to be compared with dicts if plugin in device_properties: try: plugin.setup(device_properties) found_plugins.append(plugin) except DeviceLacksExtractInfo, e: exceptions.append(e)
def setUpClass(self): # uncomment me to see whats going on # self.log = log.startLogging(sys.stdout) huawei = PluginManager.get_plugin_by_name('Huawei E220') stub = test_protocol(huawei, SerialPortStub, BufferingStateMachine) self.stub = stub
def get_os_by_lsb(self, lsb): for plugin in PluginManager.get_plugins(IOSPlugin): if plugin.is_valid() and not isinstance(osplugin, BundledDistro): return plugin
def get_os_by_lsb(self, lsb): for osplugin in PluginManager.get_plugins(IOSPlugin): if osplugin.is_valid(lsb) and not isinstance(osplugin, BundledDistro): return osplugin
def setUpClass(self): # uncomment me to see whats going on huawei = PluginManager.get_plugin_by_remote_name('E220') stub = test_protocol(huawei, SerialPortStub, BufferingStateMachine) self.stub = stub
def initialize(self): super(BundledDistro, self).initialize() for plugin in PluginManager.get_plugins(IOSPlugin): if (plugin.is_valid() and plugin.__class__ != self.__class__): self.__class__.__bases__ = (plugin.__class__, ) return
def initialize(self): super(BundledDistro, self).initialize() for plugin in PluginManager.get_plugins(IOSPlugin): if (plugin.is_valid() and plugin.__class__ != self.__class__): self.__class__.__bases__ = (plugin.__class__,) return