Ejemplo n.º 1
0
    def __init__(self, server_profile, ctrl_be, monitor):
        mforms.Box.__init__(self, True)  # True - vertical layout
        self.tasks_side = newTaskSidebar()
        self.content_box = newBox(False)

        self.tasks_side.set_selection_color(mforms.SystemColorHighlight)

        self.tabs = []
        self.name2page = {}
        self.config_ui = None
        self.closing = False
        self.tabview = newTabView(True)
        self.ctrl_be = ctrl_be
        self.old_active_tab = None
        self.server_profile = server_profile

        self.refresh_tasks_sleep_time = 2

        self.ui_profile = UIProfile(server_profile)

        # Setup self
        self.set_managed()
        self.set_release_on_add()
        self.ui_profile.apply_style(self, "main")

        if server_profile.host_os == wbaOS.windows:
            side_panel = newPanel(mforms.StyledHeaderPanel)
            side_panel.set_title(" Task and Object Browser")
            side_panel.add(self.tasks_side)
            self.add(side_panel, False, True)

            self.content_panel = newPanel(mforms.StyledHeaderPanel)
            self.content_panel.set_title(" Task and Object Browser")
            self.content_panel.add(self.content_box)
            self.add(self.content_panel, True, True)
        else:
            vbox = newBox(False)
            vbox.add(self.tasks_side, True, True)
            self.add(vbox, False, False)

            vbox = newBox(False)
            self.content_label = newHeaderLabel("")
            self.ui_profile.apply_style(self.content_label, 'content-label')
            vbox.add(self.content_label, False, False)
            vbox.add(self.content_box, True, True)
            self.add(vbox, True, True)

        self.ctrl_be.add_me_for_event("server_started", self)
        self.ctrl_be.add_me_for_event("server_stopped", self)

        # Setup tasks sidebar
        self.fill_task_sidebar()
        self.tasks_side.add_on_section_command_callback(self.section_clicked)
        self.tasks_side.show()
        self.tasks_side.set_size(220, -1)

        # Setup content box
        self.content_box.add(self.tabview, True, True)

        # Retrieve from server the log file paths if exist
        status = self.ctrl_be.is_server_running(verbose=0)
        if status in ['stopped', 'unknown'] and not all([
                self.server_profile.
                general_log_file_path,  # only proceed to parse the config file if
                self.server_profile.
                slow_log_file_path,  # any of these is missing
                self.server_profile.error_log_file_path,
                self.server_profile.log_output
        ]):

            cfg_be = wb_admin_config_file_be.WbAdminConfigFileBE(
                self.server_profile, self.ctrl_be)
            cfg_be.open_configuration_file(
                self.server_profile.config_file_path)
            options = dict(
                cfg_be.get_options(self.server_profile.config_file_section))

            if not self.server_profile.log_output and options.has_key(
                    'log-output'):
                self.server_profile.log_ouput = options['log-output']

            if not self.server_profile.general_log_file_path:
                path = options['general_log_file'] if options.has_key(
                    'general_log_file') else (
                        options['log'] if options.has_key('log') else ''
                    )  # the 'log' option is deprecated but still allowed
                if path:
                    self.server_profile.general_log_file_path = path.strip('"')

            if not self.server_profile.slow_log_file_path:
                path = options['slow_query_log_file'] if options.has_key(
                    'slow_query_log_file'
                ) else (
                    options['log-slow-queries']
                    if options.has_key('log-slow-queries') else ''
                )  # the 'log-slow-queries' option is deprecated but still allowed
                if path:
                    self.server_profile.slow_log_file_path = path.strip('"')

            if not self.server_profile.error_log_file_path and options.has_key(
                    'log-error'):
                self.server_profile.error_log_file_path = options[
                    'log-error'].strip('"')

        # Create content pages
        self.server_status_page = ServerStatusPage(server_profile, ctrl_be,
                                                   self)
        self.config_ui = WbAdminConfigFileUI(server_profile=server_profile,
                                             ctrl_be=ctrl_be,
                                             main_view=self)
        self.startup = WbAdminConfigurationStartup(ctrl_be, server_profile,
                                                   self)
        self.security = WbAdminSecurity(self.ctrl_be, server_profile, self)
        self.variables = WbAdminVariables(self.ctrl_be, server_profile, self)
        self.logs = WbAdminLogs(self.ctrl_be, server_profile, self)
        self.dump = WbAdminExport(server_profile, self.ctrl_be, self)
        self.restore = WbAdminImport(server_profile, self.ctrl_be, self)

        self.init_extensions(server_profile, self.ctrl_be)

        Utilities.add_timeout(0.5, weakcb(self, "timeout"))
        self.timeout_thread = threading.Thread(
            target=self.refresh_tasks_thread)
        self.timeout_thread.setDaemon(True)
        self.timeout_thread.start()
        self.tabview.add_tab_changed_callback(self.tab_changed)

        self.timeout(
        )  # will call self.connect_mysql() and check if mysql is running

        self.ctrl_be.continue_events(
        )  # Process events which are queue during init
        dprint_ex(1, "WBA init complete")

        self.tasks_side.select_entry("MANAGEMENT", "Server Status")
        self.server_status_page.page_activated()
Ejemplo n.º 2
0
    def __init__(self, server_profile, ctrl_be, monitor):
        mforms.Box.__init__(self, True)  # True - vertical layout
        self.tasks_side = newTaskSidebar()
        self.content_box = newBox(False)

        self.tasks_side.set_selection_color(mforms.SystemHighlight)

        self.tabs = []
        self.name2page = {}
        self.config_ui = None
        self.closing = False
        self.tabview = newTabView(True)
        self.ctrl_be = ctrl_be
        self.old_active_tab = None
        self.server_profile = server_profile

        self.refresh_tasks_sleep_time = 2

        self.ui_profile = UIProfile(server_profile)

        # Setup self
        self.set_managed()
        self.ui_profile.apply_style(self, "main")

        if server_profile.host_os == wbaOS.windows:
            side_panel = newPanel(mforms.StyledHeaderPanel)
            side_panel.set_title(" Task and Object Browser")
            side_panel.add(self.tasks_side)
            self.add(side_panel, False, True)

            self.content_panel = newPanel(mforms.StyledHeaderPanel)
            self.content_panel.set_title(" Task and Object Browser")
            self.content_panel.add(self.content_box)
            self.add(self.content_panel, True, True)
        else:
            vbox = newBox(False)
            vbox.add(self.tasks_side, True, True)
            self.add(vbox, False, False)

            vbox = newBox(False)
            self.content_label = newHeaderLabel("")
            self.ui_profile.apply_style(self.content_label, 'content-label')
            vbox.add(self.content_label, False, False)
            vbox.add(self.content_box, True, True)
            self.add(vbox, True, True)

        self.ctrl_be.add_me_for_event("server_started", self)
        self.ctrl_be.add_me_for_event("server_stopped", self)

        # Setup tasks sidebar
        self.fill_task_sidebar()
        self.tasks_side.add_on_section_command_callback(self.section_clicked)
        self.tasks_side.show()
        self.tasks_side.set_size(220, -1)

        # Setup content box
        self.content_box.add(self.tabview, True, True)

        # Create content pages
        self.server_status_page = ServerStatusPage(server_profile, ctrl_be,
                                                   self)
        self.config_ui = WbAdminConfigFileUI(server_profile=server_profile,
                                             ctrl_be=ctrl_be,
                                             main_view=self)
        self.startup = WbAdminConfigurationStartup(ctrl_be, server_profile,
                                                   self)
        self.security = WbAdminSecurity(self.ctrl_be, server_profile, self)
        self.variables = WbAdminVariables(self.ctrl_be, server_profile, self)
        self.logs = WbAdminLogs(self.ctrl_be, server_profile, self)
        self.dump = WbAdminExport(server_profile, self.ctrl_be, self)

        Utilities.add_timeout(0.5, weakcb(self, "timeout"))
        self.timeout_thread = threading.Thread(
            target=self.refresh_tasks_thread)
        self.timeout_thread.setDaemon(True)
        self.timeout_thread.start()
        self.tabview.add_tab_changed_callback(self.tab_changed)

        self.timeout(
        )  # will call self.connect_mysql() and check if mysql is running

        self.ctrl_be.continue_events(
        )  # Process events which are queue during init
        dprint_ex(1, "WBA init complete")

        self.tasks_side.select_entry("MANAGEMENT", "Server Status")
        self.server_status_page.page_activated()