当前位置: 首页>>代码示例>>Python>>正文


Python Workbench.register方法代码示例

本文整理汇总了Python中enaml.workbench.api.Workbench.register方法的典型用法代码示例。如果您正苦于以下问题:Python Workbench.register方法的具体用法?Python Workbench.register怎么用?Python Workbench.register使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在enaml.workbench.api.Workbench的用法示例。


在下文中一共展示了Workbench.register方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: task_workbench

# 需要导入模块: from enaml.workbench.api import Workbench [as 别名]
# 或者: from enaml.workbench.api.Workbench import register [as 别名]
def task_workbench(monkeypatch, app_dir):
    """Setup the workbench in such a way that the task manager can be tested.

    """
    def exit_err(self):
        if self._delayed:
            raise Exception('Unexpected exceptions occured :\n' +
                            pformat(self._delayed))

    monkeypatch.setattr(ErrorsPlugin, 'exit_error_gathering', exit_err)
    workbench = Workbench()
    workbench.register(CoreManifest())
    workbench.register(AppManifest())
    workbench.register(PreferencesManifest())
    workbench.register(ErrorsManifest())
    workbench.register(DependenciesManifest())
    workbench.register(TasksManagerManifest())

    yield workbench

    for m_id in ('ecpy.tasks', 'ecpy.app.dependencies', 'ecpy.app.errors',
                 'ecpy.app.preferences', 'ecpy.app'):
        try:
            workbench.unregister(m_id)
        except ValueError:
            pass
开发者ID:MatthieuDartiailh,项目名称:ecpy,代码行数:28,代码来源:fixtures.py

示例2: TestApplyMagFieldView

# 需要导入模块: from enaml.workbench.api import Workbench [as 别名]
# 或者: from enaml.workbench.api.Workbench import register [as 别名]
class TestApplyMagFieldView(object):

    def setup(self):
        self.workbench = Workbench()
        self.workbench.register(CoreManifest())
        self.workbench.register(StateManifest())
        self.workbench.register(PreferencesManifest())
        self.workbench.register(InstrManagerManifest())
        self.workbench.register(TaskManagerManifest())

        self.root = RootTask(should_stop=Event(), should_pause=Event())
        self.task = ApplyMagFieldTask(task_name='Test')
        self.root.children_task.append(self.task)
        self.root.run_time['drivers'] = {'Test': InstrHelper}

    def teardown(self):
        close_all_windows()

        self.workbench.unregister(u'hqc_meas.task_manager')
        self.workbench.unregister(u'hqc_meas.instr_manager')
        self.workbench.unregister(u'hqc_meas.preferences')
        self.workbench.unregister(u'hqc_meas.state')
        self.workbench.unregister(u'enaml.workbench.core')

    def test_view1(self):
        # Intantiate a view with no selected interface and select one after
        window = enaml.widgets.api.Window()
        core = self.workbench.get_plugin('enaml.workbench.core')
        view = ApplyMagFieldView(window, task=self.task, core=core)
        window.show()

        process_app_events()
开发者ID:MatthieuDartiailh,项目名称:HQCMeas,代码行数:34,代码来源:test_apply_mag_field_task.py

示例3: workbench

# 需要导入模块: from enaml.workbench.api import Workbench [as 别名]
# 或者: from enaml.workbench.api.Workbench import register [as 别名]
def workbench():
    """Create a workbench and register basic manifests.

    """
    workbench = Workbench()
    workbench.register(CoreManifest())
    workbench.register(ErrorsManifest())
    return workbench
开发者ID:pombredanne,项目名称:ecpy,代码行数:10,代码来源:test_plugin.py

示例4: TestPNASetRFFrequencyView

# 需要导入模块: from enaml.workbench.api import Workbench [as 别名]
# 或者: from enaml.workbench.api.Workbench import register [as 别名]
class TestPNASetRFFrequencyView(object):

    def setup(self):
        self.workbench = Workbench()
        self.workbench.register(CoreManifest())
        self.workbench.register(StateManifest())
        self.workbench.register(PreferencesManifest())
        self.workbench.register(InstrManagerManifest())
        self.workbench.register(TaskManagerManifest())

        self.root = RootTask(should_stop=Event(), should_pause=Event())
        self.task = SetRFFrequencyTask(task_name='Test')
        self.root.children_task.append(self.task)
        self.root.run_time['drivers'] = {'Test': InstrHelper}

    def teardown(self):
        close_all_windows()

        self.workbench.unregister(u'hqc_meas.task_manager')
        self.workbench.unregister(u'hqc_meas.instr_manager')
        self.workbench.unregister(u'hqc_meas.preferences')
        self.workbench.unregister(u'hqc_meas.state')
        self.workbench.unregister(u'enaml.workbench.core')

    def test_view1(self):
        # Intantiate a view with no selected interface and select one after
        window = enaml.widgets.api.Window()
        core = self.workbench.get_plugin('enaml.workbench.core')
        view = RFFrequencyView(window, task=self.task, core=core)
        window.show()

        process_app_events()

        assert_in('AgilentPNA', view.drivers)
        self.task.selected_driver = 'AgilentPNA'
        process_app_events()
        assert_is_instance(self.task.interface, PNASetRFFrequencyInterface)

    def test_view2(self):
        # Intantiate a view with a selected interface.
        self.task.interface = PNASetRFFrequencyInterface(task=self.task)
        self.task.frequency = '1.0'
        self.task.selected_driver = 'AgilentPNA'

        interface = self.task.interface

        window = enaml.widgets.api.Window()
        core = self.workbench.get_plugin('enaml.workbench.core')
        RFFrequencyView(window, task=self.task, core=core)
        window.show()

        process_app_events()

        assert_is(self.task.interface, interface)
开发者ID:MatthieuDartiailh,项目名称:HQCMeas,代码行数:56,代码来源:test_pna_tasks.py

示例5: task_workbench

# 需要导入模块: from enaml.workbench.api import Workbench [as 别名]
# 或者: from enaml.workbench.api.Workbench import register [as 别名]
def task_workbench(monkeypatch, app_dir):
    """Setup the workbench in such a way that the task manager can be tested.

    """
    def exit_err(self):
        if self._delayed:
            raise Exception('Unexpected exceptions occured :\n' +
                            pformat(self._delayed))

    monkeypatch.setattr(ErrorsPlugin, 'exit_error_gathering', exit_err)
    workbench = Workbench()
    workbench.register(CoreManifest())
    workbench.register(AppManifest())
    workbench.register(PreferencesManifest())
    workbench.register(ErrorsManifest())
    workbench.register(DependenciesManifest())
    workbench.register(TasksManagerManifest())

    return workbench
开发者ID:pombredanne,项目名称:ecpy,代码行数:21,代码来源:conftest.py

示例6: TestSaveArrayView

# 需要导入模块: from enaml.workbench.api import Workbench [as 别名]
# 或者: from enaml.workbench.api.Workbench import register [as 别名]
class TestSaveArrayView(object):

    def setup(self):
        self.workbench = Workbench()
        self.workbench.register(CoreManifest())
        self.workbench.register(StateManifest())
        self.workbench.register(PreferencesManifest())
        self.workbench.register(TaskManagerManifest())

        self.root = RootTask(should_stop=Event(), should_pause=Event())
        self.task = SaveArrayTask(task_name='Test')
        self.root.children_task.append(self.task)

    def teardown(self):
        close_all_windows()

        self.workbench.unregister(u'hqc_meas.task_manager')
        self.workbench.unregister(u'hqc_meas.preferences')
        self.workbench.unregister(u'hqc_meas.state')
        self.workbench.unregister(u'enaml.workbench.core')

    def test_view(self):
        # Intantiate a view with no selected interface and select one after
        window = enaml.widgets.api.Window()
        view = SaveArrayView(window, task=self.task)
        window.show()

        process_app_events()
开发者ID:jf---,项目名称:HQCMeas,代码行数:30,代码来源:test_save_tasks.py

示例7: TestWhileView

# 需要导入模块: from enaml.workbench.api import Workbench [as 别名]
# 或者: from enaml.workbench.api.Workbench import register [as 别名]
class TestWhileView(object):

    def setup(self):
        self.workbench = Workbench()
        self.workbench.register(CoreManifest())
        self.workbench.register(StateManifest())
        self.workbench.register(PreferencesManifest())
        self.workbench.register(TaskManagerManifest())

        self.root = RootTask(should_stop=Event(), should_pause=Event())
        self.task = WhileTask(task_name='Test', condition='rr')
        self.root.children_task.append(self.task)

    def teardown(self):
        close_all_windows()

        self.workbench.unregister(u'hqc_meas.task_manager')
        self.workbench.unregister(u'hqc_meas.preferences')
        self.workbench.unregister(u'hqc_meas.state')
        self.workbench.unregister(u'enaml.workbench.core')

    def test_view(self):
        # Intantiate a view with no selected interface and select one after
        window = enaml.widgets.api.Window()
        core = self.workbench.get_plugin('enaml.workbench.core')
        view = WhileView(window, task=self.task, core=core)
        window.show()

        process_app_events()

        assert_equal(view.widgets()[1].text, 'rr')

        view.widgets()[1].text = 'test'
        process_app_events()
        assert_equal(self.task.condition, 'test')
开发者ID:MatthieuDartiailh,项目名称:HQCMeas,代码行数:37,代码来源:test_while_task.py

示例8: dep_workbench

# 需要导入模块: from enaml.workbench.api import Workbench [as 别名]
# 或者: from enaml.workbench.api.Workbench import register [as 别名]
def dep_workbench():
    """Setup the workbench to test dependencies related capabilities.

    """
    workbench = Workbench()
    workbench.register(CoreManifest())
    workbench.register(DependenciesManifest())
    workbench.register(BuildDep())
    workbench.register(RuntimeDep())

    yield workbench

    workbench.unregister('ecpy.app.dependencies')
    workbench.unregister('enaml.workbench.core')
开发者ID:MatthieuDartiailh,项目名称:ecpy,代码行数:16,代码来源:test_plugin.py

示例9: TestDefinitionView

# 需要导入模块: from enaml.workbench.api import Workbench [as 别名]
# 或者: from enaml.workbench.api.Workbench import register [as 别名]
class TestDefinitionView(object):

    def setup(self):
        self.workbench = Workbench()
        self.workbench.register(CoreManifest())
        self.workbench.register(StateManifest())
        self.workbench.register(PreferencesManifest())
        self.workbench.register(TaskManagerManifest())

        self.root = RootTask(should_stop=Event(), should_pause=Event())
        self.task = DefinitionTask(task_name='Test')
        self.root.children_task.append(self.task)

    def teardown(self):
        close_all_windows()

        self.workbench.unregister(u'hqc_meas.task_manager')
        self.workbench.unregister(u'hqc_meas.preferences')
        self.workbench.unregister(u'hqc_meas.state')
        self.workbench.unregister(u'enaml.workbench.core')

    def test_view(self):
        # Intantiate a view.
        window = enaml.widgets.api.Window()
        DefinitionView(window, task=self.task)
        window.show()

        process_app_events()

        self.task.definitions = [('1', '2.0'), ('2', "*['a', 1.0]")]

        process_app_events()
开发者ID:MatthieuDartiailh,项目名称:HQCMeas,代码行数:34,代码来源:test_def_task.py

示例10: TestLoadArrayView

# 需要导入模块: from enaml.workbench.api import Workbench [as 别名]
# 或者: from enaml.workbench.api.Workbench import register [as 别名]
class TestLoadArrayView(object):

    def setup(self):
        self.workbench = Workbench()
        self.workbench.register(CoreManifest())
        self.workbench.register(StateManifest())
        self.workbench.register(PreferencesManifest())
        self.workbench.register(TaskManagerManifest())

        self.root = RootTask(should_stop=Event(), should_pause=Event())
        self.task = LoadArrayTask(task_name='Test')
        self.root.children_task.append(self.task)

    def teardown(self):
        close_all_windows()

        self.workbench.unregister(u'hqc_meas.task_manager')
        self.workbench.unregister(u'hqc_meas.preferences')
        self.workbench.unregister(u'hqc_meas.state')
        self.workbench.unregister(u'enaml.workbench.core')

    def test_view(self):
        # Intantiate a view with no selected interface and select one after
        window = enaml.widgets.api.Window()
        core = self.workbench.get_plugin('enaml.workbench.core')
        view = LoadArrayView(window, task=self.task, core=core)
        window.show()

        process_app_events()

        assert_is(self.task.interface, None)

        assert_in('CSV', view.file_formats)
        self.task.selected_format = 'CSV'
        process_app_events()
        assert_is_instance(self.task.interface,
                           CSVLoadInterface)

    def test_view2(self):
        # Intantiate a view with a selected interface.
        interface = CSVLoadInterface()
        self.task.interface = interface
        self.task.selected_format = 'CSV'

        interface = self.task.interface

        window = enaml.widgets.api.Window()
        core = self.workbench.get_plugin('enaml.workbench.core')
        LoadArrayView(window, task=self.task, core=core)
        window.show()

        process_app_events()

        assert_is(self.task.interface, interface)
开发者ID:MatthieuDartiailh,项目名称:HQCMeas,代码行数:56,代码来源:test_load_tasks.py

示例11: workbench

# 需要导入模块: from enaml.workbench.api import Workbench [as 别名]
# 或者: from enaml.workbench.api.Workbench import register [as 别名]
def workbench():
    workbench = Workbench()
    workbench.register(CoreManifest())
    workbench.register(ContextManifest())
    workbench.register(TestManifest())

    context = workbench.get_plugin('psi.context')
    print context.selectors['default'].order
    print context.selectors['default'].parameters
    print context.context_items['repetitions'].rove
    for r in (20, 15, 10, 2):
        context.selectors['default'].add_setting(dict(repetitions=r))
    return workbench
开发者ID:bburan,项目名称:psiexperiment,代码行数:15,代码来源:test_context.py

示例12: test_registration

# 需要导入模块: from enaml.workbench.api import Workbench [as 别名]
# 或者: from enaml.workbench.api.Workbench import register [as 别名]
def test_registration(windows):
    """Test that the manifest is properly regsistered.

    """
    w = Workbench()
    w.register(CoreManifest())
    w.register(ErrorsManifest())
    w.register(PackagesManifest())

    with signal_error_raise():
        w.get_plugin('ecpy.app.packages').collect_and_register()

    # Edit the name of the package
    assert w.get_plugin('ecpy_ext_demo')
开发者ID:Ecpy,项目名称:ecpy_ext_demo,代码行数:16,代码来源:test_registration.py

示例13: TestCollectingFromConfig

# 需要导入模块: from enaml.workbench.api import Workbench [as 别名]
# 或者: from enaml.workbench.api.Workbench import register [as 别名]
class TestCollectingFromConfig(object):
    """Test collecting dependencies from ConfigObj object.

    """

    def setup(self):

        self.workbench = Workbench()
        self.workbench.register(CoreManifest())
        self.workbench.register(DependenciesManifest())
        self.workbench.register(BuildDep())

    def teardown(self):
        self.workbench.unregister('ecpy.app.dependencies')
        self.workbench.unregister('enaml.workbench.core')

    def test_collecting(self):
        """Test collecting from a dict-like object.

        """
        core = self.workbench.get_plugin('enaml.workbench.core')
        res, dep = core.invoke_command(COLLECT,
                                       {'obj': ConfigObj({'val': '1',
                                                          'dep_type': 'test'})}
                                       )
        assert res
        assert dep.keys() == ['test']

    def test_handling_errors(self, monkeypatch):
        """Test handling errors occuring when collecting dependencies.

        """
        plugin = self.workbench.get_plugin('ecpy.app.dependencies')

        for b in plugin.build_deps.contributions.values():
            monkeypatch.setattr(b, 'err', True)

        core = self.workbench.get_plugin('enaml.workbench.core')
        res, dep = core.invoke_command(COLLECT,
                                       {'obj': ConfigObj({'val': '1',
                                                          'dep_type': 'test'})}
                                       )

        assert not res
        assert 'test' in dep
开发者ID:pombredanne,项目名称:ecpy,代码行数:47,代码来源:test_plugin.py

示例14: TestCollectingFromObject

# 需要导入模块: from enaml.workbench.api import Workbench [as 别名]
# 或者: from enaml.workbench.api.Workbench import register [as 别名]
class TestCollectingFromObject(object):
    """Test collecting dependencies of live objects.

    """

    def setup(self):

        self.workbench = Workbench()
        self.workbench.register(CoreManifest())
        self.workbench.register(DependenciesManifest())
        self.workbench.register(BuildDep())
        self.workbench.register(RuntimeDep())

    def teardown(self):
        self.workbench.unregister('ecpy.app.dependencies')
        self.workbench.unregister('enaml.workbench.core')

    def test_collecting_build(self, dependent_object):
        """Test collecting only the build dependencies.

        """
        core = self.workbench.get_plugin('enaml.workbench.core')
        res, dep = core.invoke_command(COLLECT, {'obj': dependent_object})
        assert res
        assert dep.keys() == ['test']

    def test_collecting_runtime(self, dependent_object):
        """Test collecting only the runtime dependencies.

        """
        plugin = self.workbench.get_plugin('ecpy.app.dependencies')
        core = self.workbench.get_plugin('enaml.workbench.core')
        res, dep = core.invoke_command(COLLECT, {'obj': dependent_object,
                                                 'dependencies': ['runtime']},
                                       plugin)
        assert res
        assert dep.keys() == ['test_run']

    def test_collecting_all(self, dependent_object):
        """Test collecting all dependencies.

        """
        core = self.workbench.get_plugin('enaml.workbench.core')
        res, dep = core.invoke_command(COLLECT, {'obj': dependent_object,
                                                 'dependencies': ['build',
                                                                  'runtime'],
                                                 'owner': 'ecpy.test'})

        assert res
        assert dep[0].keys() == ['test']
        assert dep[1].keys() == ['test_run']

    def test_handling_errors(self, monkeypatch, dependent_object):
        """Test handling errors occuring when collecting dependencies.

        """
        plugin = self.workbench.get_plugin('ecpy.app.dependencies')

        for b in plugin.build_deps.contributions.values():
            monkeypatch.setattr(b, 'err', True)

        for r in plugin.run_deps.contributions.values():
            monkeypatch.setattr(r, 'err', True)

        core = self.workbench.get_plugin('enaml.workbench.core')
        res, dep = core.invoke_command(COLLECT, {'obj': dependent_object,
                                                 'dependencies': ['build',
                                                                  'runtime'],
                                                 'owner': 'ecpy.test'})

        assert not res
        assert 'test' in dep[0] and 'test_run' in dep[1]

    def test_handling_missing_caller(self, dependent_object):
        """Test handling a missing caller when runtime dependencies are
        requested.

        """
        core = self.workbench.get_plugin('enaml.workbench.core')
        res, dep = core.invoke_command(COLLECT, {'obj': dependent_object,
                                                 'dependencies': ['runtime']})
        assert not res
        assert 'owner' in dep

    def test_handling_unknown_dep_type(self, dependent_object):
        """Test handling an unknown dep_type.

        """
        dependent_object.dep_type = 'Unknown'
        core = self.workbench.get_plugin('enaml.workbench.core')
        res, dep = core.invoke_command(COLLECT, {'obj': dependent_object})
        assert not res
        assert 'Unknown' in dep

    def test_handling_missing_runtime_collector(self, monkeypatch,
                                                dependent_object):
        """Test handling an unknown dep_type.

        """
        plugin = self.workbench.get_plugin('ecpy.app.dependencies')
#.........这里部分代码省略.........
开发者ID:pombredanne,项目名称:ecpy,代码行数:103,代码来源:test_plugin.py

示例15: TestTemplateConfig

# 需要导入模块: from enaml.workbench.api import Workbench [as 别名]
# 或者: from enaml.workbench.api.Workbench import register [as 别名]
class TestTemplateConfig(object):
    """
    """

    test_dir = ''

    @classmethod
    def setup_class(cls):
        print complete_line(__name__ +
                            ':{}.setup_class()'.format(cls.__name__), '-', 77)
        # Creating dummy directory for prefs (avoid prefs interferences).
        cls.test_dir = os.path.join(FILE_DIR, '_temps')
        create_test_dir(cls.test_dir)

        # Creating dummy default.ini file in utils.
        util_path = os.path.join(PACKAGE_PATH, 'utils', 'preferences')
        def_path = os.path.join(util_path, 'default.ini')

        # Making the preference manager look for info in test dir.
        default = ConfigObj(def_path)
        default['folder'] = cls.test_dir
        default['file'] = 'default_test.ini'
        default.write()

        # Creating a false template.
        template_path = os.path.join(cls.test_dir, 'temp_templates')
        os.mkdir(template_path)
        conf = ConfigObj()
        conf.filename = os.path.join(template_path, 'test.ini')
        conf.update(create_template_sequence())
        conf.write()

        # Saving plugin preferences.
        man_conf = {'templates_folders': repr([template_path])}

        conf = ConfigObj(os.path.join(cls.test_dir, 'default_test.ini'))
        conf[u'hqc_meas.pulses'] = {}
        conf[u'hqc_meas.pulses'].update(man_conf)
        conf.write()

    @classmethod
    def teardown_class(cls):
        print complete_line(__name__ +
                            ':{}.teardown_class()'.format(cls.__name__), '-',
                            77)
        # Removing pref files creating during tests.
        remove_tree(cls.test_dir)

        # Restoring default.ini file in utils
        util_path = os.path.join(PACKAGE_PATH, 'utils', 'preferences')
        def_path = os.path.join(util_path, 'default.ini')
        os.remove(def_path)

    def setup(self):

        self.workbench = Workbench()
        self.workbench.register(CoreManifest())
        self.workbench.register(StateManifest())
        self.workbench.register(PreferencesManifest())
        self.workbench.register(DependenciesManifest())
        self.workbench.register(PulsesManagerManifest())

        self.plugin = self.workbench.get_plugin('hqc_meas.pulses')

    def teardown(self):
        self.workbench.unregister(u'hqc_meas.pulses')
        self.workbench.unregister(u'hqc_meas.dependencies')
        self.workbench.unregister(u'hqc_meas.preferences')
        self.workbench.unregister(u'hqc_meas.state')
        self.workbench.unregister(u'enaml.workbench.core')

    def test_init(self):
        # Test the context is properly created at config init.
        seqs, _ = self.plugin.sequences_request(['Test'])
        _, conf, doc = seqs['Test']
        t_config = TemplateConfig(template_doc=doc, template_config=conf)

        assert_items_equal(t_config.context.logical_channels, ['A', 'B'])
        assert_items_equal(t_config.context.analogical_channels,
                           ['Ch1', 'Ch2'])
        assert_equal(t_config.context.channel_mapping,
                     {'A': '', 'B': '', 'Ch1': '', 'Ch2': ''})

    def test_building_template1(self):
        # Test building a template.
        seqs, _ = self.plugin.sequences_request(['Test'])
        _, conf, doc = seqs['Test']
        t_config = TemplateConfig(template_doc=doc, template_config=conf,
                                  manager=self.plugin)
        t_config.template_name = 'Test'

        seq = t_config.build_sequence()
        assert_false(t_config.errors)
        assert_is_instance(seq, TemplateSequence)
        assert_equal(seq.name, 'Test')
        # No need to check more as build_from_config is already tested in
        # test_template_sequence.

    def test_building_template2(self):
        # Test building a template for which some dependencies are missing.
#.........这里部分代码省略.........
开发者ID:PhilipVinc,项目名称:HQCMeas,代码行数:103,代码来源:test_template_config.py


注:本文中的enaml.workbench.api.Workbench.register方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。