def prepare(self): """ Prepare console screen objects, logger, ask for widgets """ super(ConsoleStatusReporter, self).prepare() self.disabled = self.settings.get("disable", False) if self.disabled: return if sys.stdout.isatty(): self.screen = Screen() if platform.system() != 'Windows': self.__detect_console_logger() else: cols = self.settings.get('dummy-cols', self.screen_size[0]) rows = self.settings.get('dummy-rows', self.screen_size[1]) self.screen = DummyScreen(cols, rows) widgets = [] if isinstance(self.engine.provisioning, Local): for executor in self.engine.provisioning.executors: if isinstance(executor, WidgetProvider): widgets.append(executor.get_widget()) for reporter in self.engine.reporters: if isinstance(reporter, WidgetProvider): widgets.append(reporter.get_widget()) self.console = TaurusConsole(widgets) self.screen.register_palette(self.console.palette)
def test_draw_screen(self): lines = [((x[0], None, "%s\n" % x[0]), ) for x in TaurusConsole.palette] canvas = TestCanvas(lines) obj = Screen() """ :type: bzt.modules.screen.GUIScreen """ obj.register_palette(TaurusConsole.palette) obj.start() for _ in range(1, 10): obj.draw_screen((1, 1), canvas) time.sleep(0.5) if hasattr(obj, 'font'): old_font_size = obj.font['size'] obj.root.event_generate("<Control-4>") obj.root.event_generate("<Control-MouseWheel>", delta=120) if old_font_size > 0: self.assertGreater(obj.font['size'], old_font_size) else: self.assertLess(obj.font['size'], old_font_size) obj.root.event_generate("<Control-5>") obj.root.event_generate("<Control-MouseWheel>", delta=-120) self.assertEqual(obj.font['size'], old_font_size) obj.stop()
def prepare(self): """ Prepare console screen objects, logger, ask for widgets """ super(ConsoleStatusReporter, self).prepare() self.disabled = self.settings.get("disable", False) if self.disabled: return if sys.stdout.isatty(): self.screen = Screen() else: cols = self.settings.get('dummy-cols', self.screen_size[0]) rows = self.settings.get('dummy-rows', self.screen_size[1]) self.screen = DummyScreen(cols, rows) widgets = [] modules = [self.engine.provisioning ] # must create new list to not alter existing modules += self.engine.reporters modules += self.engine.services if isinstance(self.engine.provisioning, Local): modules += self.engine.provisioning.executors for executor in modules: if isinstance(executor, WidgetProvider): widgets.append(executor.get_widget()) self.console = TaurusConsole(widgets) self.screen.register_palette(self.console.palette) if isinstance(self.engine.aggregator, ResultsProvider): self.engine.aggregator.add_listener(self)
def test_window_closed(self): lines = [((x[0], None, "%s\n" % x[0]), ) for x in TaurusConsole.palette] canvas = TestCanvas(lines) obj = Screen() obj.register_palette(TaurusConsole.palette) obj.start() for _ in range(5): obj.draw_screen((1, 1), canvas) time.sleep(0.1) # closing the window obj.closed_window() # first call to draw_screen should raise ManualShutdown self.assertRaises(ManualShutdown, obj.draw_screen, (1, 1), canvas) # consecutive calls to draw_screen shouldn't raise obj.draw_screen((1, 1), canvas) obj.draw_screen((1, 1), canvas)