def instr_workbench(workbench, monkeypatch, app_dir, app): """Setup the workbench in such a way that the instrs manager can be tested. """ monkeypatch.setattr(ErrorsPlugin, 'exit_error_gathering', exit_on_err) workbench.register(CoreManifest()) workbench.register(AppManifest()) workbench.register(PreferencesManifest()) workbench.register(IconManagerManifest()) workbench.register(ErrorsManifest()) workbench.register(StateManifest()) workbench.register(DependenciesManifest()) workbench.register(InstrumentManagerManifest()) yield workbench for m_id in ('exopy.instruments', 'exopy.app.dependencies', 'exopy.app.errors', 'exopy.app.preferences', 'exopy.app.icons', 'exopy.app.states', 'exopy.app'): try: workbench.unregister(m_id) except Exception: pass # Give some time to the os to release resources linked to file # monitoring. sleep(0.1)
def measurement_workbench(workbench, monkeypatch, app_dir): """Setup the workbench in such a way that the measurement plugin can be tested. """ monkeypatch.setattr(ErrorsPlugin, 'exit_error_gathering', exit_on_err) workbench.register(CoreManifest()) workbench.register(AppManifest()) workbench.register(PreferencesManifest()) workbench.register(IconManagerManifest()) workbench.register(ErrorsManifest()) workbench.register(DependenciesManifest()) workbench.register(StateManifest()) workbench.register(MeasureManifest()) workbench.register(TextMonitorManifest()) yield workbench for m_id in ('exopy.measurement.monitors.text_monitor', 'exopy.measurement', 'exopy.app.dependencies', 'exopy.app.errors', 'exopy.app.icons', 'exopy.app.preferences', 'exopy.app'): try: workbench.unregister(m_id) except ValueError: pass # Give some time to the os to release resources linked to file # monitoring. sleep(0.1)
def pref_workbench(workbench): """Register the plugins resuired to test the preferences plugin. """ workbench.register(CoreManifest()) workbench.register(AppManifest()) workbench.register(ErrorsManifest()) return workbench
def err_workbench(workbench): """Create a workbench and register basic manifests. """ workbench.register(CoreManifest()) workbench.register(ErrorsManifest()) workbench.register(PackagesManifest()) return workbench
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('exopy.app.packages').collect_and_register() # Edit the name of the package assert w.get_plugin('exopy_ext_demo')
def workbench_and_tools(exopy_qtbot): """Create a workbench to test closing of the application window. """ workbench = Workbench() workbench.register(CoreManifest()) workbench.register(UIManifest()) workbench.register(AppManifest()) workbench.register(ErrorsManifest()) closing = ClosingContributor1() workbench.register(closing) closed = ClosedContributor() workbench.register(closed) return workbench, closing, closed
def pulses_workbench(monkeypatch, app_dir): """Setup the workbench in such a way that the pulses manager can be tested. """ monkeypatch.setattr(ErrorsPlugin, 'exit_error_gathering', exit_on_err) workbench = Workbench() workbench.register(CoreManifest()) workbench.register(AppManifest()) workbench.register(PreferencesManifest()) workbench.register(ErrorsManifest()) workbench.register(StateManifest()) workbench.register(DependenciesManifest()) workbench.register(MeasureManifest()) workbench.register(PulsesManagerManifest()) yield workbench for m_id in ('exopy.pulses', 'exopy.app.dependencies', 'exopy.app.errors', 'exopy.app.preferences', 'exopy.app'): try: workbench.unregister(m_id) except Exception: pass
def setup(self): self.workbench = Workbench() self.workbench.register(AppManifest()) self.workbench.register(CoreManifest()) self.workbench.register(ErrorsManifest())
def setup(self): self.workbench = Workbench() self.workbench.register(CoreManifest()) self.workbench.register(ErrorsManifest()) self.workbench.register(DeclaratorManifest())
def main(cmd_line_args=None): """Main entry point of the Exopy application. """ # Build parser from ArgParser and parse arguemnts parser = ArgParser() parser.add_choice('workspaces', 'exopy.measurement.workspace', 'measurement') parser.add_argument("-s", "--nocapture", help="Don't capture stdout/stderr", action='store_true') parser.add_argument("-w", "--workspace", help='Select start-up workspace', default='measurement', choices='workspaces') parser.add_argument("-r", "--reset-app-folder", help='Reset the application startup folder.', action='store_true') modifiers = [] for i, ep in enumerate(iter_entry_points('exopy_cmdline_args')): try: modifier, priority = ep.load(require=False) modifiers.append((ep, modifier, priority, i)) except Exception as e: text = 'Error loading extension %s' % ep.name content = ('The following error occurred when trying to load the ' 'entry point {} :\n {}'.format(ep.name, e)) details = format_exc() display_startup_error_dialog(text, content, details) modifiers.sort(key=itemgetter(1, 2)) try: for m in modifiers: m[1](parser) except Exception as e: text = 'Error modifying cmd line arguments' content = ('The following error occurred when the entry point {} ' 'tried to add cmd line options :\n {}'.format(ep.name, e)) details = format_exc() display_startup_error_dialog(text, content, details) try: args = parser.parse_args(cmd_line_args) except BaseException as e: if e.args == (0, ): sys.exit(0) text = 'Failed to parse cmd line arguments' content = ('The following error occurred when trying to parse the ' 'command line arguments :\n {}'.format(e)) details = format_exc() display_startup_error_dialog(text, content, details) # Patch Thread to use sys.excepthook setup_thread_excepthook() workbench = Workbench() workbench.register(CoreManifest()) workbench.register(UIManifest()) workbench.register(AppManifest()) workbench.register(StateManifest()) workbench.register(ErrorsManifest()) workbench.register(PreferencesManifest()) workbench.register(IconManagerManifest()) workbench.register(LogManifest()) workbench.register(PackagesManifest()) workbench.register(DependenciesManifest()) workbench.register(InstrumentManagerManifest()) workbench.register(TasksManagerManifest()) workbench.register(MeasureManifest()) workbench.register(TextMonitorManifest()) ui = workbench.get_plugin(u'enaml.workbench.ui') # Create the application try: app = workbench.get_plugin('exopy.app') app.run_app_startup(args) except Exception as e: text = 'Error starting plugins' content = ('The following error occurred when executing plugins ' 'application start ups :\n {}'.format(e)) details = format_exc() display_startup_error_dialog(text, content, details) core = workbench.get_plugin('enaml.workbench.core') # Install global except hook. if not args.nocapture: core.invoke_command('exopy.app.errors.install_excepthook', {}) # Select workspace core.invoke_command('enaml.workbench.ui.select_workspace', {'workspace': args.workspace}, workbench) ui = workbench.get_plugin(u'enaml.workbench.ui') ui.show_window() ui.window.maximize() ui.start_application() core.invoke_command('enaml.workbench.ui.close_workspace', {}, workbench) # Unregister all contributed packages workbench.unregister('exopy.app.packages') workbench.unregister('exopy.measurement.monitors.text_monitor') workbench.unregister('exopy.measurement') workbench.unregister('exopy.tasks') workbench.unregister('exopy.instruments') workbench.unregister('exopy.app.icons') workbench.unregister('exopy.app.preferences') workbench.unregister('exopy.app.states') workbench.unregister('exopy.app.dependencies') workbench.unregister('exopy.app.errors') workbench.unregister('exopy.app.logging') workbench.unregister('exopy.app') workbench.unregister(u'enaml.workbench.ui') workbench.unregister(u'enaml.workbench.core')