示例#1
0
 def register_console_logging_handler(cls, lgr, level=logging.INFO):
     """Registers console logging handler to given logger."""
     console_handler = logger.DevassistantClHandler(sys.stdout)
     console_handler.setFormatter(logger.DevassistantClFormatter())
     console_handler.setLevel(level)
     cls.cur_handler = console_handler
     lgr.addHandler(console_handler)
示例#2
0
    def __init__(self):
        # Used for debugging
        console_handler = logging.StreamHandler(stream=sys.stdout)
        console_formatter = logging.Formatter(
            '%(asctime)s %(levelname)s - %(message)s')
        console_handler.setFormatter(console_formatter)
        console_handler.setLevel(logging.INFO)
        logger.logger_gui.addHandler(console_handler)
        # End used for debugging
        # Setup logger for warnings and errors that can occur before running assistants
        #  (e.g. errors from loading faulty assistants)
        # TODO: are the logger.Devassistant* classes good enough or do we need special ones?
        ch = logger.DevassistantClHandler(stream=sys.stderr)
        ch.setFormatter(logger.DevassistantClFormatter())
        ch.setLevel(logging.WARNING)
        logger.logger.addHandler(ch)
        # End setup logger
        self.builder = Gtk.Builder()
        self.builder.add_from_file(GLADE_FILE)
        self.main_win = self.builder.get_object("mainWindow")
        self.gui_helper = gui_helper.GuiHelper(self)
        self.path_window = path_window.PathWindow(self, self.main_win,
                                                  self.builder,
                                                  self.gui_helper)
        self.run_window = run_window.RunWindow(self, self.builder,
                                               self.gui_helper)
        self.main_handlers = {
            "on_mainWindow_delete_event": self.delete_event,
            "on_browsePathBtn_clicked": self.path_window.browse_path,
            "on_nextPathBtn_clicked": self.path_window.next_window,
            "on_pathWindow_delete_event": self.delete_event,
            "on_runWindow_delete_event": self.run_window.delete_event,
            "on_runWindow_destroy": self.run_window.destroy,
            "on_prevPathBtn_clicked": self.path_window.prev_window,
            "on_debugBtn_clicked": self.run_window.debug_btn_clicked,
            "on_clipboardBtn_clicked": self.run_window.clipboard_btn_clicked,
            "on_backBtn_clicked": self.run_window.back_btn_clicked,
            "on_mainBtn_clicked": self.run_window.main_btn_clicked,
            "on_entryProjectName_changed":
            self.path_window.project_name_changed,
            "on_dirName_changed": self.path_window.dir_name_changed,
        }
        self.builder.connect_signals(self.main_handlers)
        self.label_main_window = self.builder.get_object("sublabel")
        self.label_project_name = self.builder.get_object("labelProjectName")
        self.box4 = self.builder.get_object("box4")
        self.box4.set_spacing(12)
        self.box4.set_border_width(12)
        # Creating Notebook widget.
        self.notebook = self.gui_helper.create_notebook()
        self.notebook.set_has_tooltip(True)
        self.box4.pack_start(self.notebook, True, True, 0)
        # Devassistant creator part
        self.top_assistant = TopAssistant()
        for sub_as in self.top_assistant.get_subassistants():
            tool_tip = self.gui_helper.get_formatted_description(
                sub_as.description)
            label = self.gui_helper.create_label(sub_as.fullname,
                                                 wrap_mode=False,
                                                 tooltip=tool_tip)
            self.notebook.append_page(self._create_notebook_page(sub_as),
                                      label)

        self.notebook.show()
        self.kwargs = dict()
        self.data = dict()
        self.dev_assistant_path = []
        self.main_win.show_all()
        # Load configuration file
        config_manager.load_configuration_file()
        # Thread should be defined here
        # because of timeout and threads sharing.
        GLib.threads_init()
        Gdk.threads_init()
        Gdk.threads_enter()
        Gtk.main()
        Gdk.threads_leave()