def configure(self): self.info_panel_width = self.get_option("info_panel_width", self.info_panel_width) self.short_only = int(self.get_option("short_only", '0')) if not int(self.get_option("disable_all_colors", '0')): self.console_markup = RealConsoleMarkup() else: self.console_markup = NoConsoleMarkup() for color in self.get_option("disable_colors", '').split(' '): self.console_markup.__dict__[color] = '' self.screen = Screen(self.info_panel_width, self.console_markup) try: aggregator = self.core.get_plugin_of_type(AggregatorPlugin) aggregator.add_result_listener(self) except KeyError: self.log.debug("No aggregator for console") self.screen.block_rows = [] self.screen.info_panel_percent = 100
class ConsoleOnlinePlugin(AbstractPlugin, AggregateResultListener): ''' Console plugin ''' SECTION = 'console' def __init__(self, core): AbstractPlugin.__init__(self, core) self.screen = None self.render_exception = None self.console_markup = None self.remote_translator = None self.info_panel_width = '33' self.short_only = 0 # these three provide non-blocking console output self.__console_view = None self.__writer_thread = None self.__writer_event = None @staticmethod def get_key(): return __file__ def get_available_options(self): return ["info_panel_width", "short_only", "disable_all_colors", "disable_colors"] def configure(self): self.info_panel_width = self.get_option("info_panel_width", self.info_panel_width) self.short_only = int(self.get_option("short_only", '0')) if not int(self.get_option("disable_all_colors", '0')): self.console_markup = RealConsoleMarkup() else: self.console_markup = NoConsoleMarkup() for color in self.get_option("disable_colors", '').split(' '): self.console_markup.__dict__[color] = '' self.screen = Screen(self.info_panel_width, self.console_markup) try: aggregator = self.core.get_plugin_of_type(AggregatorPlugin) aggregator.add_result_listener(self) except KeyError: self.log.debug("No aggregator for console") self.screen.block_rows = [] self.screen.info_panel_percent = 100 def __console_writer(self): while True: self.__writer_event.wait() self.__writer_event.clear() if self.__console_view: if not self.short_only: self.log.debug("Writing console view to STDOUT") sys.stdout.write(self.console_markup.clear) sys.stdout.write(self.__console_view) sys.stdout.write(self.console_markup.TOTAL_RESET) if self.remote_translator: self.remote_translator.send_console(self.__console_view) def is_test_finished(self): if not self.__writer_thread: self.__writer_event = threading.Event() self.__writer_thread = threading.Thread(target=self.__console_writer) self.__writer_thread.daemon = True self.__writer_thread.start() try: self.__console_view = self.screen.render_screen().encode('utf-8') except Exception, ex: self.log.warn("Exception inside render: %s", traceback.format_exc(ex)) self.render_exception = ex self.__console_view = "" self.__writer_event.set() return -1
class ConsoleOnlinePlugin(AbstractPlugin, AggregateResultListener): ''' Console plugin ''' SECTION = 'console' def __init__(self, core): AbstractPlugin.__init__(self, core) self.screen = None self.render_exception = None self.console_markup = None self.remote_translator = None self.info_panel_width = '33' self.short_only = 0 # these three provide non-blocking console output self.__console_view = None self.__writer_thread = None self.__writer_event = None @staticmethod def get_key(): return __file__ def get_available_options(self): return [ "info_panel_width", "short_only", "disable_all_colors", "disable_colors" ] def configure(self): self.info_panel_width = self.get_option("info_panel_width", self.info_panel_width) self.short_only = int(self.get_option("short_only", '0')) if not int(self.get_option("disable_all_colors", '0')): self.console_markup = RealConsoleMarkup() else: self.console_markup = NoConsoleMarkup() for color in self.get_option("disable_colors", '').split(' '): self.console_markup.__dict__[color] = '' self.screen = Screen(self.info_panel_width, self.console_markup) try: aggregator = self.core.get_plugin_of_type(AggregatorPlugin) aggregator.add_result_listener(self) except KeyError: self.log.debug("No aggregator for console") self.screen.block_rows = [] self.screen.info_panel_percent = 100 def __console_writer(self): while True: self.__writer_event.wait() self.__writer_event.clear() if self.__console_view: if not self.short_only: self.log.debug("Writing console view to STDOUT") sys.stdout.write(self.console_markup.clear) sys.stdout.write(self.__console_view) sys.stdout.write(self.console_markup.TOTAL_RESET) if self.remote_translator: self.remote_translator.send_console(self.__console_view) def is_test_finished(self): if not self.__writer_thread: self.__writer_event = threading.Event() self.__writer_thread = threading.Thread( target=self.__console_writer) self.__writer_thread.daemon = True self.__writer_thread.start() try: self.__console_view = self.screen.render_screen().encode('utf-8') except Exception, ex: self.log.warn("Exception inside render: %s", traceback.format_exc(ex)) self.render_exception = ex self.__console_view = "" self.__writer_event.set() return -1