def __init__(self): plugins = [ CorePlugin(), TasksPlugin(), DummyExtensionPluginWithDataView() ] super(DummyWfManagerWithPlugins, self).__init__(plugins=plugins)
def test_dynamically_added_category(self): """ dynamically added category """ from envisage.core_plugin import CorePlugin class PluginA(Plugin): id = 'A' categories = List(contributes_to='envisage.categories') def _categories_default(self): """ Trait initializer. """ bar_category = Category( class_name=PKG + '.bar_category.BarCategory', target_class_name=CorePluginTestCase.__module__ + '.Bar') return [bar_category] core = CorePlugin() a = PluginA() # Start with just the core plugin. application = TestApplication(plugins=[core]) application.start() # Now add a plugin that contains a category. application.add_plugin(a) # Create the target class. class Bar(HasTraits): x = Int # Make sure the category was imported and added. self.assertTrue('y' in Bar.class_traits())
def run_gui(): logging.basicConfig(level=logging.DEBUG) debug = ("--debug" in sys.argv) plugins = [ CorePlugin(), TasksPlugin(), FlowTaskPlugin(debug=debug), ImportPlugin(), ThresholdPlugin(), HistogramPlugin(), HexbinPlugin(), ScatterplotPlugin(), RangePlugin(), Range2DPlugin(), PolygonPlugin(), BarChartPlugin(), Stats1DPlugin(), BinningPlugin() ] app = CytoflowApplication(id='edu.mit.synbio.cytoflow', plugins=plugins) app.run() logging.shutdown()
def app_factory(klass, user): """ assemble the plugins return a Pychron TaskApplication """ pychron_plugin = PychronTasksPlugin() plugins = [ CorePlugin(), myTasksPlugin(), pychron_plugin, # FoobotPlugin(), LoggerPlugin(), UsersPlugin() ] # if UpdatePlugin is not None: # plugins.append(UpdatePlugin()) plugins += get_hardware_plugins() plugins += get_user_plugins() app = klass(username=user, plugins=plugins) # set key bindings update_key_bindings(pychron_plugin.actions) return app
def test_preferences(self): """ preferences """ # The core plugin is the plugin that offers the preferences extension # point. from envisage.core_plugin import CorePlugin class PluginA(Plugin): id = 'A' preferences = List(contributes_to='envisage.preferences') def _preferences_default(self): """ Trait initializer. """ return ['file://' + resource_filename(PKG, 'preferences.ini')] core = CorePlugin() a = PluginA() application = TestApplication(plugins=[core, a]) application.run() # Make sure we can get one of the preferences. self.assertEqual('42', application.preferences.get('enthought.test.x'))
def test_dynamically_added_preferences(self): """ dynamically added preferences """ # The core plugin is the plugin that offers the preferences extension # point. from envisage.core_plugin import CorePlugin class PluginA(Plugin): id = 'A' preferences = List(contributes_to='envisage.preferences') def _preferences_default(self): """ Trait initializer. """ return ['file://' + resource_filename(PKG, 'preferences.ini')] core = CorePlugin() a = PluginA() # Start with just the core plugin. application = TestApplication(plugins=[core]) application.start() # Now add a plugin that contains a preference. application.add_plugin(a) # Make sure we can get one of the preferences. self.assertEqual('42', application.preferences.get('enthought.test.x')) return
def get_plugins(): """Get list of default plugins to use for Mayavi.""" from envisage.core_plugin import CorePlugin from envisage.ui.workbench.workbench_plugin import WorkbenchPlugin from envisage.plugins.python_shell.python_shell_plugin import PythonShellPlugin from tvtk.plugins.scene.scene_plugin import ScenePlugin from tvtk.plugins.scene.ui.scene_ui_plugin import SceneUIPlugin from mayavi.plugins.mayavi_plugin import MayaviPlugin from mayavi.plugins.mayavi_ui_plugin import MayaviUIPlugin from envisage.developer.developer_plugin import DeveloperPlugin from envisage.developer.ui.developer_ui_plugin import DeveloperUIPlugin plugins = [CorePlugin(), WorkbenchPlugin(), MayaviPlugin(), MayaviUIPlugin(), ScenePlugin(), SceneUIPlugin(), PythonShellPlugin(), DeveloperPlugin(), DeveloperUIPlugin(), # TextEditorPlugin() ] return plugins
def __init__(self): plugins = [ CorePlugin(), TasksPlugin(), DummyUIPlugin(), DummyUIPluginOld() ] super(DummyUIWfManager, self).__init__(plugins=plugins)
def __init__(self, filename=None): plugins = [CorePlugin(), TasksPlugin(), ProbeWfManagerPlugin(filename)] super(ProbeWfManager, self).__init__(plugins=plugins) # 'Run' the application by creating windows without an event loop self.run = self._create_windows
def test_dynamically_added_service_offer(self): """ dynamically added service offer """ from envisage.core_plugin import CorePlugin class IMyService(Interface): pass class PluginA(Plugin): id = 'A' service_offers = List( contributes_to='envisage.service_offers' ) def _service_offers_default(self): """ Trait initializer. """ service_offers = [ ServiceOffer( protocol=IMyService, factory=self._my_service_factory ) ] return service_offers def _my_service_factory(self, **properties): """ Service factory. """ return 42 core = CorePlugin() a = PluginA() # Start off with just the core plugin. application = TestApplication(plugins=[core]) application.start() # Make sure the service does not exist! service = application.get_service(IMyService) self.assertIsNone(service) # Make sure the service offer exists... extensions = application.get_extensions('envisage.service_offers') self.assertEqual(0, len(extensions)) # Now add a plugin that contains a service offer. application.add_plugin(a) # Make sure the service offer exists... extensions = application.get_extensions('envisage.service_offers') self.assertEqual(1, len(extensions)) # ... and that the core plugin responded to the new service offer and # published it in the service registry. service = application.get_service(IMyService) self.assertEqual(42, service)
def main(argv): """ Run the application. """ logging.basicConfig(level=logging.WARNING) plugins = [CorePlugin(), TasksPlugin(), AttractorsPlugin()] app = AttractorsApplication(plugins=plugins) app.run() logging.shutdown()
def __init__(self): plugins = [CorePlugin(), TasksPlugin(), ProbePyFibreGUIPlugin()] super(ProbePyFibreGUI, self).__init__(plugins=plugins) # 'Run' the application by creating windows # without an event loop self.run = self._create_windows
def main(): """ Run the application. """ # Create an application containing the appropriate plugins. application = Application( id = 'acme.motd', plugins = [CorePlugin(), MOTDPlugin(), SoftwareQuotesPlugin()] ) # Run it! return application.run()
def main(): application = Application(id='Update Checker Tester', plugins=[UpdateChecker()]) application = WorkbenchApplication(id='update_checker_tester', name='Update Checker', plugins=[ CorePlugin(), WorkbenchPlugin(), UpdateCheckerPlugin(), ]) application.run()
def test_class_load_hooks(self): """ class load hooks """ from envisage.core_plugin import CorePlugin def on_class_loaded(cls): """ Called when a class has been loaded. """ on_class_loaded.cls = cls return class PluginA(Plugin): id = 'A' class_load_hooks = List( [ ClassLoadHook( class_name = CorePluginTestCase.__module__ + '.Baz', on_load = on_class_loaded, ) ], contributes_to='envisage.class_load_hooks' ) core = CorePlugin() a = PluginA() application = TestApplication(plugins=[core, a]) application.start() # Make sure we ignore a class that we are not interested in! class Bif(HasTraits): pass # Make sure the class load hook was *ignored*. self.assert_(not hasattr(on_class_loaded, 'cls')) # Create the target class. class Baz(HasTraits): pass # Make sure the class load hook was called. # # fixme: The following assertion was commented out. Please don't do # that! If a test fails we need to work out why - otherwise you have # just completely removed the benefits of having tests in the first # place! This test works for me on Python 2.4! self.assertEqual(Baz, on_class_loaded.cls) return
def main(): """ Run the application. """ # Create an application with the specified plugins. acmelab = Acmelab( plugins=[CorePlugin(), WorkbenchPlugin(), AcmeWorkbenchPlugin(),] ) # Run it! This starts the application, starts the GUI event loop, and when # that terminates, stops the application. acmelab.run() return
def launch(): root = logging.getLogger() root.setLevel(logging.DEBUG) shandler = logging.StreamHandler() shandler.setLevel(logging.DEBUG) root.addHandler(shandler) plugins = [CorePlugin(), TasksPlugin(), WellpyPlugin()] app = WellpyApplication(plugins=plugins) app.run()
def test_contributes_service(self): plugins = [ CorePlugin(), TasksPlugin(), FactoryRegistryPlugin(), WfManagerPlugin(workflow_file=None), ExampleCustomUIPlugin() ] wfmanager = WfManager(plugins=plugins) wfmanager.plugin_manager.start() self.assertEqual(len(wfmanager.get_services(IContributedUI)), 2) self.assertEqual(len(wfmanager.get_services(IDataView)), 2)
def main(workflow_file, debug, window_size, profile): """Launches the FORCE workflow manager application""" if debug is False: logging.basicConfig(filename="force_wfmanager.log", filemode="w") else: logging.basicConfig(filename="force_wfmanager.log", filemode="w", level=logging.DEBUG) if profile: import cProfile import pstats profiler = cProfile.Profile() profiler.enable() log = logging.getLogger(__name__) plugins = [ CorePlugin(), TasksPlugin(), FactoryRegistryPlugin(), WfManagerPlugin(workflow_file=workflow_file) ] mgr = extension.ExtensionManager(namespace='force.bdss.extensions', invoke_on_load=True) def import_extensions(ext): log.info("Found extension {}".format(ext.name)) plugins.append(ext.obj) try: mgr.map(import_extensions) except NoMatches: log.info("No extensions found") wfmanager = WfManager(plugins=plugins, window_size=window_size) wfmanager.run() if profile: profiler.disable() from sys import version_info fname = 'force_wfmanager-{}-{}.{}.{}'.format(__version__, version_info.major, version_info.minor, version_info.micro) profiler.dump_stats(fname + '.prof') with open(fname + '.pstats', 'w') as fp: stats = pstats.Stats(profiler, stream=fp).sort_stats('cumulative') stats.print_stats()
def test_service_offers(self): """ service offers """ from envisage.core_plugin import CorePlugin class IMyService(Interface): pass class PluginA(Plugin): id = 'A' service_offers = List( contributes_to='envisage.service_offers' ) def _service_offers_default(self): """ Trait initializer. """ service_offers = [ ServiceOffer( protocol=IMyService, factory=self._my_service_factory ) ] return service_offers def _my_service_factory(self, **properties): """ Service factory. """ return 42 core = CorePlugin() a = PluginA() application = TestApplication(plugins=[core, a]) application.start() # Lookup the service. self.assertEqual(42, application.get_service(IMyService)) # Stop the core plugin. application.stop_plugin(core) # Make sure th service has gone. self.assertEqual(None, application.get_service(IMyService)) return
def test_dynamically_added_class_load_hooks(self): """ dynamically class load hooks """ from envisage.core_plugin import CorePlugin def on_class_loaded(cls): """ Called when a class has been loaded. """ on_class_loaded.cls = cls return class PluginA(Plugin): id = 'A' class_load_hooks = List([ ClassLoadHook( class_name=CorePluginTestCase.__module__ + '.Baz', on_load=on_class_loaded, ) ], contributes_to='envisage.class_load_hooks') core = CorePlugin() a = PluginA() # Start with just the core plugin. application = TestApplication(plugins=[core]) application.start() # Now add a plugin that contains a class load hook. application.add_plugin(a) # Make sure we ignore a class that we are not interested in! class Bif(HasTraits): pass # Make sure the class load hook was *ignored*. self.assert_(not hasattr(on_class_loaded, 'cls')) # Create the target class. class Baz(HasTraits): pass # Make sure the class load hook was called. self.assertEqual(Baz, on_class_loaded.cls) return
def main(): """ Run the application. """ # Create an application with the specified plugins. lorenz_application = LorenzApplication(plugins=[ CorePlugin(), WorkbenchPlugin(), LorenzPlugin(), LorenzUIPlugin() ]) # Run it! This starts the application, starts the GUI event loop, and when # that terminates, stops the application. lorenz_application.run() return
def main(): from envisage.api import Application from envisage.core_plugin import CorePlugin from motd.plugins.motd_service import MOTDServicePlugin, MOTDStartupPlugin from motd.plugins.messages import MessagesPlugin application = Application( id='motd_startup', plugins=[ CorePlugin(), MOTDServicePlugin(), MessagesPlugin(), MOTDStartupPlugin() ] ) # Run it! application.run()
def test_kernel_namespace_extension_point(self): class NamespacePlugin(Plugin): kernel_namespace = List(contributes_to=IPYTHON_NAMESPACE) def _kernel_namespace_default(self): return [('y', 'hi')] plugins = [CorePlugin(), IPythonKernelPlugin(), NamespacePlugin()] app = Application(plugins=plugins, id='test') app.start() try: kernel = app.get_service(IPYTHON_KERNEL_PROTOCOL) kernel.init_ipkernel(gui_backend=None) self.assertIn('y', kernel.namespace) self.assertEqual(kernel.namespace['y'], 'hi') finally: app.stop()
def __init__(self, evaluate, workflow_file, toolkit='null', **traits): self._set_ets_toolkit(toolkit) if isinstance(workflow_file, str): workflow_file = WorkflowFile(path=workflow_file) operation = self._create_operation(evaluate) operation.workflow_file = workflow_file plugins = [CorePlugin(), FactoryRegistryPlugin()] self._load_plugins(plugins) super(BDSSApplication, self).__init__( workflow_file=workflow_file, operation=operation, plugins=plugins, **traits )
def app_factory(klass): """ assemble the plugins return a Pychron TaskApplication """ plugins = [ CorePlugin(), myTasksPlugin(), LoggerPlugin(), ] if UpdatePlugin is not None: plugins.append(UpdatePlugin()) plugins += get_hardware_plugins() plugins += get_user_plugins() app = klass(plugins=plugins) return app
def running_app(self, plugins=None): """ Returns a context manager that provides a running application. Parameters ---------- plugins : list of Plugin, optional Plugins to use in the application, other than the CorePlugin (which is always included). If not given, an IPythonKernelPlugin is instantiated and used. """ if plugins is None: plugins = [IPythonKernelPlugin(init_ipkernel=True)] app = Application(plugins=[CorePlugin()] + plugins, id="test") app.start() try: yield app finally: app.stop()
def test_kernel_service(self): # See that we can get the IPython kernel service when the plugin is # there. plugins = [CorePlugin(), IPythonKernelPlugin()] app = Application(plugins=plugins, id='test') # Starting the app starts the kernel plugin. The IPython kernel # service should now be available. app.start() kernel = app.get_service(IPYTHON_KERNEL_PROTOCOL) self.assertIsNotNone(kernel) self.assertIsInstance(kernel, InternalIPKernel) # Initialize the kernel. Normally, the application does it when # it starts. kernel.init_ipkernel(gui_backend=None) # Stopping the application should shut the kernel down. app.stop() self.assertIsNone(kernel.ipkernel)
def test_categories(self): """ categories """ from envisage.core_plugin import CorePlugin class PluginA(Plugin): id = 'A' categories = List(contributes_to='envisage.categories') def _categories_default(self): """ Trait initializer. """ bar_category = Category( class_name = PKG + '.bar_category.BarCategory', target_class_name = CorePluginTestCase.__module__ + '.Bar' ) return [bar_category] core = CorePlugin() a = PluginA() application = TestApplication(plugins=[core, a]) application.start() # Create the target class. class Bar(HasTraits): x = Int # Make sure the category was imported and added. # # fixme: The following assertion was commented out. Please don't do # that! If a test fails we need to work out why - otherwise you have # just completely removed the benefits of having tests in the first # place! This test works for me on Python 2.4! self.assert_('y' in Bar.class_traits()) return
def main(): """ Runs the application. """ # Create the application. application = WorkbenchApplication( id='testProject_extended', plugins=[ CorePlugin(), WorkbenchPlugin(), ProjectPlugin(), EnvProjectPlugin(), PythonShellPlugin(), # FIXME: This is uncommented for now until we have the new TreeEditor # implementation in place that can understand domain-objects that have # been abstracted to an INode interface. #DataPlugin(), ]) # Run the application. application.run() return