def update_ui_state(self):
        show_advanced_options = self.check_show_advanced_options.isChecked()

        # version
        def cb_python_versions(versions):
            for version in versions:
                if version.executable == self.program.executable:
                    self.label_version.setText(version.version)
                    return

            self.label_version.setText('<unknown>')

        self.get_executable_versions('python', cb_python_versions)

        # start mode
        start_mode_api_name      = self.program.cast_custom_option_value('python.start_mode', unicode, '<unknown>')
        start_mode               = Constants.get_python_start_mode(start_mode_api_name)
        start_mode_script_file   = start_mode == Constants.PYTHON_START_MODE_SCRIPT_FILE
        start_mode_module_name   = start_mode == Constants.PYTHON_START_MODE_MODULE_NAME
        start_mode_command       = start_mode == Constants.PYTHON_START_MODE_COMMAND
        start_mode_web_interface = start_mode == Constants.PYTHON_START_MODE_WEB_INTERFACE

        self.label_version_title.setVisible(not start_mode_web_interface)
        self.label_version.setVisible(not start_mode_web_interface)
        self.label_start_mode.setText(Constants.python_start_mode_display_names[start_mode])
        self.line.setVisible(not start_mode_web_interface)
        self.check_show_advanced_options.setVisible(not start_mode_web_interface)

        # script file
        self.label_script_file_title.setVisible(start_mode_script_file)
        self.label_script_file.setVisible(start_mode_script_file)
        self.label_script_file.setText(self.program.cast_custom_option_value('python.script_file', unicode, '<unknown>'))

        # module name
        self.label_module_name_title.setVisible(start_mode_module_name)
        self.label_module_name.setVisible(start_mode_module_name)
        self.label_module_name.setText(self.program.cast_custom_option_value('python.module_name', unicode, '<unknown>'))

        # command
        self.label_command_title.setVisible(start_mode_command)
        self.label_command.setVisible(start_mode_command)
        self.label_command.setText(self.program.cast_custom_option_value('python.command', unicode, '<unknown>'))

        # url
        self.label_url_title.setVisible(start_mode_web_interface)
        self.label_url.setVisible(start_mode_web_interface)
        self.label_url.setText(self.url_template.replace('<SERVER>', 'red-brick').replace('<IDENTIFIER>', self.program.identifier))

        # working directory
        self.label_working_directory_title.setVisible(show_advanced_options and not start_mode_web_interface)
        self.label_working_directory.setVisible(show_advanced_options and not start_mode_web_interface)
        self.label_working_directory.setText(self.program.working_directory)

        # options
        self.label_options_title.setVisible(show_advanced_options and not start_mode_web_interface)
        self.label_options.setVisible(show_advanced_options and not start_mode_web_interface)
        self.label_options.setText('\n'.join(self.program.cast_custom_option_value_list('python.options', unicode, [])))
Exemple #2
0
    def update_ui_state(self):
        show_advanced_options = self.check_show_advanced_options.isChecked()

        # version
        def cb_python_versions(versions):
            for version in versions:
                if version.executable == self.program.executable:
                    self.label_version.setText(version.version)
                    return

            self.label_version.setText('<unknown>')

        self.get_executable_versions('python', cb_python_versions)

        # start mode
        start_mode_api_name      = self.program.cast_custom_option_value('python.start_mode', str, '<unknown>')
        start_mode               = Constants.get_python_start_mode(start_mode_api_name)
        start_mode_script_file   = start_mode == Constants.PYTHON_START_MODE_SCRIPT_FILE
        start_mode_module_name   = start_mode == Constants.PYTHON_START_MODE_MODULE_NAME
        start_mode_command       = start_mode == Constants.PYTHON_START_MODE_COMMAND
        start_mode_web_interface = start_mode == Constants.PYTHON_START_MODE_WEB_INTERFACE

        self.label_version_title.setVisible(not start_mode_web_interface)
        self.label_version.setVisible(not start_mode_web_interface)
        self.label_start_mode.setText(Constants.python_start_mode_display_names[start_mode])
        self.line.setVisible(not start_mode_web_interface)
        self.check_show_advanced_options.setVisible(not start_mode_web_interface)

        # script file
        self.label_script_file_title.setVisible(start_mode_script_file)
        self.label_script_file.setVisible(start_mode_script_file)
        self.label_script_file.setText(self.program.cast_custom_option_value('python.script_file', str, '<unknown>'))

        # module name
        self.label_module_name_title.setVisible(start_mode_module_name)
        self.label_module_name.setVisible(start_mode_module_name)
        self.label_module_name.setText(self.program.cast_custom_option_value('python.module_name', str, '<unknown>'))

        # command
        self.label_command_title.setVisible(start_mode_command)
        self.label_command.setVisible(start_mode_command)
        self.label_command.setText(self.program.cast_custom_option_value('python.command', str, '<unknown>'))

        # url
        self.label_url_title.setVisible(start_mode_web_interface)
        self.label_url.setVisible(start_mode_web_interface)
        self.label_url.setText(self.url_template.replace('<SERVER>', 'red-brick').replace('<IDENTIFIER>', self.program.identifier))

        # working directory
        self.label_working_directory_title.setVisible(show_advanced_options and not start_mode_web_interface)
        self.label_working_directory.setVisible(show_advanced_options and not start_mode_web_interface)
        self.label_working_directory.setText(self.program.working_directory)

        # options
        self.label_options_title.setVisible(show_advanced_options and not start_mode_web_interface)
        self.label_options.setVisible(show_advanced_options and not start_mode_web_interface)
        self.label_options.setText('\n'.join(self.program.cast_custom_option_value_list('python.options', str, [])))
Exemple #3
0
    def initializePage(self):
        self.set_formatted_sub_title(
            'Specify how the {language} program [{name}] should be executed.')

        self.update_combo_version('python', self.combo_version)

        self.combo_start_mode.setCurrentIndex(
            Constants.DEFAULT_PYTHON_START_MODE)
        self.combo_script_file_selector.reset()
        self.label_url.setText(
            self.url_template.replace('<SERVER>', 'red-brick').replace(
                '<IDENTIFIER>', self.get_field('identifier')))
        self.check_show_advanced_options.setChecked(False)
        self.combo_working_directory_selector.reset()
        self.option_list_editor.reset()

        # if a program exists then this page is used in an edit wizard
        program = self.wizard().program

        if program != None:
            # start mode
            start_mode_api_name = program.cast_custom_option_value(
                'python.start_mode', str, '<unknown>')
            start_mode = Constants.get_python_start_mode(start_mode_api_name)

            self.combo_start_mode.setCurrentIndex(start_mode)

            # script file
            self.combo_script_file_selector.set_current_text(
                program.cast_custom_option_value('python.script_file', str,
                                                 ''))

            # module name
            self.edit_module_name.setText(
                program.cast_custom_option_value('python.module_name', str,
                                                 ''))

            # command
            self.edit_command.setText(
                program.cast_custom_option_value('python.command', str, ''))

            # working directory
            self.combo_working_directory_selector.set_current_text(
                program.working_directory)

            # options
            self.option_list_editor.clear()

            for option in program.cast_custom_option_value_list(
                    'python.options', str, []):
                self.option_list_editor.add_item(option)

        self.update_ui_state()