Esempio n. 1
0
 def run(self, module_info, pre=None, post=None, **kwargs):
     '''Run a module
     
     module_info - the module_info of the module to run
     
     pre - list of PreprocessorPlugins to run before running module
     
     post - list of PostprocessorPlugins to run after running module
     
     *kwargs - names and values for input parameters
     '''
     input_map = J.make_map(kwargs)
     if pre is not None:
         pre = J.static_call("java/util/Arrays", "asList",
                             "([Ljava/lang/Object;)Ljava/util/List;",
                             pre)
     if post is not None:
         post = J.static_call("java/util/Arrays", "asList",
                              "([Ljava/lang/Object;)Ljava/util/List;",
                              post)
     future = J.call(
         self.o, "run", "(Lorg/scijava/module/ModuleInfo;"
         "Ljava/util/List;"
         "Ljava/util/List;"
         "Ljava/util/Map;)"
         "Ljava/util/concurrent/Future;", module_info, pre, post,
         input_map)
     return J.call(
         self.o, "waitFor",
         "(Ljava/util/concurrent/Future;)Lorg/scijava/module/Module;",
         future)
Esempio n. 2
0
 def run(self, module_info,
         pre = None,
         post = None,
         **kwargs):
     '''Run a module
     
     module_info - the module_info of the module to run
     
     pre - list of PreprocessorPlugins to run before running module
     
     post - list of PostprocessorPlugins to run after running module
     
     *kwargs - names and values for input parameters
     '''
     input_map = J.make_map(kwargs)
     if pre is not None:
         pre = J.static_call("java/util/Arrays", "asList",
                             "([Ljava/lang/Object;)Ljava/util/List;",
                             pre)
     if post is not None:
         post = J.static_call("java/util/Arrays", "asList",
                              "([Ljava/lang/Object;)Ljava/util/List;",
                              post)
     future = J.call(
         self.o, "run", 
         "(Lorg/scijava/module/ModuleInfo;"
         "Ljava/util/List;"
         "Ljava/util/List;"
         "Ljava/util/Map;)"
         "Ljava/util/concurrent/Future;",
         module_info, pre, post, input_map)
     return J.call(
         self.o, "waitFor", 
         "(Ljava/util/concurrent/Future;)Lorg/scijava/module/Module;",
         future)
    def run_command(self, command_class, inputs, outputs):
        '''Run an imageJ command

        command_class - the command's dotted class name

        inputs - a dictionary of key/value pairs for the command's inputs

        outputs - a dictionary of keys to be filled with the command's outputs
        '''
        module_index = ij2.get_module_service(self.context).getIndex()
        module_infos = module_index.getS('org.scijava.command.CommandInfo')
        module_info = filter(lambda x:x.getClassName() == command_class,
                             module_infos)[0]
        svc = ij2.get_command_service(self.context)
        input_map = J.make_map(**inputs)
        future = svc.run(module_info.o, True, input_map.o)
        module = future.get()
        for key in list(outputs):
            module_item = module_info.getOutput(key)
            outputs[key] = module_item.getValue(module)
Esempio n. 4
0
 def run_command(self, command_class, inputs, outputs):
     '''Run an imageJ command
     
     command_class - the command's dotted class name
     
     inputs - a dictionary of key/value pairs for the command's inputs
     
     outputs - a dictionary of keys to be filled with the command's outputs
     '''
     module_index = ij2.get_module_service(self.context).getIndex()
     module_infos = module_index.getS('org.scijava.command.CommandInfo')
     module_info = filter(lambda x: x.getClassName() == command_class,
                          module_infos)[0]
     svc = ij2.get_command_service(self.context)
     input_map = J.make_map(**inputs)
     future = svc.run(module_info.o, True, input_map.o)
     module = future.get()
     for key in list(outputs):
         module_item = module_info.getOutput(key)
         outputs[key] = module_item.getValue(module)