Example #1
0
    def run(self):
        self.parse_command_line()

        # Instantiate class with proper environment
        if not self.instance:
            self.instance = self.cls()
        plugin = self.instance

        if self.options.inspect:
            from ion.plugin.info import PluginInfo
            print PluginInfo.from_instance(plugin)
            return self.EXIT_SUCCESS

        if self.options.bctable_columns:
            from ion.plugin.barcodetable_columns import available_columns
            print json.dumps(available_columns(), indent=1)
            return

        if self.options.runmode == "launch":
            return plugin.launch_wrapper(dry_run=self.options.dry_run)

        if self.options.runmode == "block":
            if not self.options.block:
                LOG.fatal("Block runmode requires --block identifier")
                return self.EXIT_ERROR
            return plugin.block(self.options.block)
Example #2
0
    def run(self):
        self.parse_command_line()

        # Instantiate class with proper environment
        if not self.instance:
            self.instance = self.cls()
        plugin = self.instance

        if self.options.inspect:
            from ion.plugin.info import PluginInfo
            print PluginInfo.from_instance(plugin)
            return self.EXIT_SUCCESS

        if self.options.bctable_columns:
            from ion.plugin.barcodetable_columns import available_columns
            print json.dumps(available_columns(), indent=1)
            return

        if self.options.runmode == "launch":
            return plugin.launch_wrapper(dry_run=self.options.dry_run)

        if self.options.runmode == "block":
            if not self.options.block:
                LOG.fatal("Block runmode requires --block identifier")
                return self.EXIT_ERROR
            return plugin.block(self.options.block)
Example #3
0
def get_info_from_script(name, script, context=None):
    from ion.plugin.loader import cache
    from ion.plugin.info import PluginInfo
    mod = cache.load_module(name, script)
    cls = cache.get_plugin(name)
    if not cls:
        return None
    plugin = cls()
    ## TODO plugin = cls(**context)
    info = PluginInfo.from_instance(plugin)
    return info
Example #4
0
def get_info_from_script(name, script, context=None):
    from ion.plugin.loader import cache
    from ion.plugin.info import PluginInfo
    mod = cache.load_module(name, script)
    cls = cache.get_plugin(name)
    if not cls:
        return None
    plugin = cls()
    ## TODO plugin = cls(**context)
    info = PluginInfo.from_instance(plugin)
    return info
Example #5
0
def check_plugin(cls):
    assert(cls.name)
    #assert(cls.__name__ ==  cls.name)
    #assert(cls.__version__)
    #assert(cls.version)

    p = cls()
    #assertIsInstance(p, IonPlugin, msg='Plugin not instance of IonPlugin')
    assert isinstance(p, IonPlugin)
    log.info("Plugin Instance: %s", p)
    j = PluginInfo.from_instance(p)
    assert j
Example #6
0
def check_plugin(cls):
    assert (cls.name)
    #assert(cls.__name__ ==  cls.name)
    #assert(cls.__version__)
    #assert(cls.version)

    p = cls()
    #assertIsInstance(p, IonPlugin, msg='Plugin not instance of IonPlugin')
    assert isinstance(p, IonPlugin)
    log.info("Plugin Instance: %s", p)
    j = PluginInfo.from_instance(p)
    assert j
Example #7
0
def check_plugin(cls):
    p = cls()
    if not p:
        return
    logger.info("Plugin Instance: %s", p)
    info = PluginInfo.from_instance(p)
    assert info
    assert info.version
    infojson = str(info)
    assert infojson
    infodict = json.loads(infojson)
    assert infodict['version']

    logger.debug("Plugin info:\n%s ", infojson)
Example #8
0
def check_plugin(cls):
    p = cls()
    if not p:
        return
    logger.info("Plugin Instance: %s", p)
    info = PluginInfo.from_instance(p)
    assert info
    assert info.version
    infojson = str(info)
    assert infojson
    infodict = json.loads(infojson)
    assert infodict['version']

    logger.debug("Plugin info:\n%s ", infojson)
Example #9
0
def get_info_from_script(name, script, context=None, add_to_store=True):
    from ion.plugin.loader import cache
    from ion.plugin.info import PluginInfo
    mod = cache.load_module(name, script, add_to_store)

    # if the load module command returned a None object, then lets raise an exception based on what happened
    if not mod:
        if name in cache.module_errors:
            raise cache.module_errors[name]
        else:
            raise Exception("Error loading the module.")

    cls = cache.get_plugin(name)
    if not cls:
        raise Exception("The python module loaded but no classes which extend 'IonPlugin' registered themselves with the framework.")
    plugin = cls()
    return PluginInfo.from_instance(plugin)
Example #10
0
def get_info_from_script(name, script, context=None, add_to_store=True):
    from ion.plugin.loader import cache
    from ion.plugin.info import PluginInfo
    mod = cache.load_module(name, script, add_to_store)

    # if the load module command returned a None object, then lets raise an exception based on what happened
    if not mod:
        if name in cache.module_errors:
            raise cache.module_errors[name]
        else:
            raise Exception("Error loading the module.")

    cls = cache.get_plugin(name)
    if not cls:
        raise Exception(
            "The python module loaded but no classes which extend 'IonPlugin' registered themselves with the framework."
        )
    plugin = cls()
    return PluginInfo.from_instance(plugin)