def update_ui_state(self): show_advanced_options = self.check_show_advanced_options.isChecked() # flavor flavor_api_name = self.program.cast_custom_option_value('javascript.flavor', str, '<unknown>') flavor = Constants.get_javascript_flavor(flavor_api_name) flavor_browser = flavor == Constants.JAVASCRIPT_FLAVOR_BROWSER flavor_nodejs = flavor == Constants.JAVASCRIPT_FLAVOR_NODEJS if flavor_browser: self.label_flavor.setText('Client-Side') elif flavor_nodejs: def cb_nodejs_versions(versions): for version in versions: if version.executable == self.program.executable: self.label_flavor.setText('Server-Side (Node.js {0})'.format(version.version)) return self.label_flavor.setText('Server-Side (Node.js)') self.get_executable_versions('nodejs', cb_nodejs_versions) self.check_show_advanced_options.setVisible(flavor_nodejs) self.line.setVisible(flavor_nodejs) # start mode start_mode_api_name = self.program.cast_custom_option_value('javascript.start_mode', str, '<unknown>') start_mode = Constants.get_javascript_start_mode(start_mode_api_name) start_mode_script_file = start_mode == Constants.JAVASCRIPT_START_MODE_SCRIPT_FILE start_mode_command = start_mode == Constants.JAVASCRIPT_START_MODE_COMMAND self.label_start_mode_title.setVisible(flavor_nodejs) self.label_start_mode.setVisible(flavor_nodejs) self.label_start_mode.setText(Constants.javascript_start_mode_display_names[start_mode]) # script file self.label_script_file_title.setVisible(flavor_nodejs and start_mode_script_file) self.label_script_file.setVisible(flavor_nodejs and start_mode_script_file) self.label_script_file.setText(self.program.cast_custom_option_value('javascript.script_file', str, '<unknown>')) # command self.label_command_title.setVisible(flavor_nodejs and start_mode_command) self.label_command.setVisible(flavor_nodejs and start_mode_command) self.label_command.setText(self.program.cast_custom_option_value('javascript.command', str, '<unknown>')) # working directory self.label_working_directory_title.setVisible(flavor_nodejs and show_advanced_options) self.label_working_directory.setVisible(flavor_nodejs and show_advanced_options) self.label_working_directory.setText(self.program.working_directory) # options self.label_options_title.setVisible(flavor_nodejs and show_advanced_options) self.label_options.setVisible(flavor_nodejs and show_advanced_options) self.label_options.setText('\n'.join(self.program.cast_custom_option_value_list('javascript.options', str, [])))
def update_ui_state(self): show_advanced_options = self.check_show_advanced_options.isChecked() # flavor flavor_api_name = self.program.cast_custom_option_value('javascript.flavor', unicode, '<unknown>') flavor = Constants.get_javascript_flavor(flavor_api_name) flavor_browser = flavor == Constants.JAVASCRIPT_FLAVOR_BROWSER flavor_nodejs = flavor == Constants.JAVASCRIPT_FLAVOR_NODEJS if flavor_browser: self.label_flavor.setText('Client-Side') elif flavor_nodejs: def cb_nodejs_versions(versions): for version in versions: if version.executable == self.program.executable: self.label_flavor.setText('Server-Side (Node.js {0})'.format(version.version)) return self.label_flavor.setText('Server-Side (Node.js)') self.get_executable_versions('nodejs', cb_nodejs_versions) self.label_start_mode_title.setVisible(flavor_nodejs) self.label_start_mode.setVisible(flavor_nodejs) self.check_show_advanced_options.setVisible(flavor_nodejs) self.line.setVisible(flavor_nodejs) self.label_working_directory_title.setVisible(flavor_nodejs and show_advanced_options) self.label_working_directory.setVisible(flavor_nodejs and show_advanced_options) self.label_options_title.setVisible(flavor_nodejs and show_advanced_options) self.label_options.setVisible(flavor_nodejs and show_advanced_options) # start mode start_mode_api_name = self.program.cast_custom_option_value('javascript.start_mode', unicode, '<unknown>') start_mode = Constants.get_javascript_start_mode(start_mode_api_name) start_mode_script_file = start_mode == Constants.JAVASCRIPT_START_MODE_SCRIPT_FILE start_mode_command = start_mode == Constants.JAVASCRIPT_START_MODE_COMMAND self.label_start_mode.setText(Constants.javascript_start_mode_display_names[start_mode]) self.label_script_file_title.setVisible(flavor_nodejs and start_mode_script_file) self.label_script_file.setVisible(flavor_nodejs and start_mode_script_file) self.label_command_title.setVisible(flavor_nodejs and start_mode_command) self.label_command.setVisible(flavor_nodejs and start_mode_command) # script file self.label_script_file.setText(self.program.cast_custom_option_value('javascript.script_file', unicode, '<unknown>')) # command self.label_command.setText(self.program.cast_custom_option_value('javascript.command', unicode, '<unknown>')) # working directory self.label_working_directory.setText(self.program.working_directory) # options self.label_options.setText('\n'.join(self.program.cast_custom_option_value_list('javascript.options', unicode, [])))
def cb_success(programs): sorted_programs = {} for program in programs: first_upload = program.cast_custom_option_value('first_upload', int, 0) if first_upload in sorted_programs: sorted_programs[first_upload][program.identifier] = program else: sorted_programs[first_upload] = {program.identifier: program} for first_upload in sorted(sorted_programs.keys()): for identifier in sorted(sorted_programs[first_upload].keys()): program = sorted_programs[first_upload][identifier] language = program.cast_custom_option_value('language', str, '<unknown>') try: language = Constants.get_language_display_name(language) except: pass item = QTreeWidgetItem([program.cast_custom_option_value('name', str, '<unknown>'), identifier, language]) self.tree_programs.addTopLevelItem(item) item.setSelected(True) self.refresh_in_progress = False self.update_ui_state() self.tree_programs.setFocus()
def cb_nodejs_versions(versions): if versions[0].version != None: node_version_str = ' ' + versions[0].version else: node_version_str = '' self.combo_flavor.clear() self.combo_flavor.addItem('Client-Side (Browser)', '/bin/false') self.combo_flavor.addItem( 'Server-Side (Node.js{0})'.format(node_version_str), versions[0].executable) # if a program exists then this page is used in an edit wizard if self.wizard().program != None: program = self.wizard().program flavor_api_name = program.cast_custom_option_value( 'javascript.flavor', str, '<unknown>') flavor = Constants.get_javascript_flavor(flavor_api_name) if flavor == Constants.JAVASCRIPT_FLAVOR_BROWSER: executable = '/bin/false' else: executable = program.executable set_current_combo_index_from_data(self.combo_flavor, executable) self.combo_flavor.setEnabled(True) self.completeChanged.emit()
def initializePage(self): self.set_formatted_sub_title( 'Specify when the {language} program [{name}] should be executed.') self.combo_start_mode.setCurrentIndex(Constants.DEFAULT_START_MODE) # if a program exists then this page is used in an edit wizard program = self.wizard().program if program != None: self.combo_start_mode.setCurrentIndex( Constants.get_start_mode(program.start_mode)) self.check_continue_after_error.setChecked( program.continue_after_error) self.spin_start_interval.setValue(program.start_interval) if program.start_mode == REDProgram.START_MODE_CRON: self.edit_start_fields.setText(program.start_fields) elif self.combo_start_mode.count() <= Constants.START_MODE_SEPARATOR: self.combo_start_mode.insertSeparator( Constants.START_MODE_SEPARATOR) self.combo_start_mode.insertItem(Constants.START_MODE_ONCE, 'Once After Upload') self.update_ui_state() self.update_interval_help()
def update_ui_state(self): show_advanced_options = self.check_show_advanced_options.isChecked() # version def cb_octave_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('octave', cb_octave_versions) # start mode start_mode_api_name = self.program.cast_custom_option_value('octave.start_mode', str, '<unknown>') start_mode = Constants.get_octave_start_mode(start_mode_api_name) start_mode_script_file = start_mode == Constants.OCTAVE_START_MODE_SCRIPT_FILE self.label_start_mode.setText(Constants.octave_start_mode_display_names[start_mode]) # 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('octave.script_file', str, '<unknown>')) # working directory self.label_working_directory_title.setVisible(show_advanced_options) self.label_working_directory.setVisible(show_advanced_options) self.label_working_directory.setText(self.program.working_directory) # options self.label_options_title.setVisible(show_advanced_options) self.label_options.setVisible(show_advanced_options) self.label_options.setText('\n'.join(self.program.cast_custom_option_value_list('octave.options', str, [])))
def update_ui_state(self): show_advanced_options = self.check_show_advanced_options.isChecked() # version def cb_mono_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('mono', cb_mono_versions) # start mode start_mode_api_name = self.program.cast_custom_option_value('csharp.start_mode', str, '<unknown>') start_mode = Constants.get_csharp_start_mode(start_mode_api_name) start_mode_executable = start_mode == Constants.CSHARP_START_MODE_EXECUTABLE self.label_start_mode.setText(Constants.csharp_start_mode_display_names[start_mode]) # executable self.label_executable_title.setVisible(start_mode_executable) self.label_executable.setVisible(start_mode_executable) self.label_executable.setText(self.program.cast_custom_option_value('csharp.executable', str, '<unknown>')) # working directory self.label_working_directory_title.setVisible(show_advanced_options) self.label_working_directory.setVisible(show_advanced_options) self.label_working_directory.setText(self.program.working_directory) # options self.label_options_title.setVisible(show_advanced_options) self.label_options.setVisible(show_advanced_options) self.label_options.setText('\n'.join(self.program.cast_custom_option_value_list('csharp.options', str, [])))
def update_ui_state(self): show_advanced_options = self.check_show_advanced_options.isChecked() compile_from_source = self.program.cast_custom_option_value('c.compile_from_source', bool, False) # start mode start_mode_api_name = self.program.cast_custom_option_value('c.start_mode', str, '<unknown>') start_mode = Constants.get_c_start_mode(start_mode_api_name) start_mode_executable = start_mode == Constants.C_START_MODE_EXECUTABLE self.label_start_mode.setText(Constants.c_start_mode_display_names[start_mode]) # executable self.label_executable_title.setVisible(start_mode_executable) self.label_executable.setVisible(start_mode_executable) self.label_executable.setText(self.program.cast_custom_option_value('c.executable', str, '')) # compile from source if compile_from_source: self.label_compile_from_source.setText('Enabled') else: self.label_compile_from_source.setText('Disabled') # working directory self.label_working_directory_title.setVisible(show_advanced_options) self.label_working_directory.setVisible(show_advanced_options) self.label_working_directory.setText(self.program.working_directory) # make options self.label_make_options_title.setVisible(compile_from_source and show_advanced_options) self.label_make_options.setVisible(compile_from_source and show_advanced_options) self.label_make_options.setText('\n'.join(self.program.cast_custom_option_value_list('c.make_options', str, [])))
def update_ui_state(self): show_advanced_options = self.check_show_advanced_options.isChecked() # version def cb_octave_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('octave', cb_octave_versions) # start mode start_mode_api_name = self.program.cast_custom_option_value('octave.start_mode', unicode, '<unknown>') start_mode = Constants.get_octave_start_mode(start_mode_api_name) start_mode_script_file = start_mode == Constants.OCTAVE_START_MODE_SCRIPT_FILE self.label_start_mode.setText(Constants.octave_start_mode_display_names[start_mode]) # 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('octave.script_file', unicode, '<unknown>')) # working directory self.label_working_directory_title.setVisible(show_advanced_options) self.label_working_directory.setVisible(show_advanced_options) self.label_working_directory.setText(self.program.working_directory) # options self.label_options_title.setVisible(show_advanced_options) self.label_options.setVisible(show_advanced_options) self.label_options.setText('\n'.join(self.program.cast_custom_option_value_list('octave.options', unicode, [])))
def update_ui_state(self): show_advanced_options = self.check_show_advanced_options.isChecked() # start mode start_mode_api_name = self.program.cast_custom_option_value('delphi.start_mode', unicode, '<unknown>') start_mode = Constants.get_delphi_start_mode(start_mode_api_name) start_mode_executable = start_mode == Constants.DELPHI_START_MODE_EXECUTABLE self.label_start_mode.setText(Constants.delphi_start_mode_display_names[start_mode]) # executable self.label_executable_title.setVisible(start_mode_executable) self.label_executable.setVisible(start_mode_executable) self.label_executable.setText(self.program.cast_custom_option_value('delphi.executable', unicode, '')) # compile from source compile_from_source = self.program.cast_custom_option_value('delphi.compile_from_source', bool, False) if compile_from_source: self.label_compile_from_source.setText('Enabled') else: self.label_compile_from_source.setText('Disabled') # build system build_system_api_name = self.program.cast_custom_option_value('delphi.build_system', unicode, '<unknown>') build_system = Constants.get_delphi_build_system(build_system_api_name) build_system_fpcmake = build_system == Constants.DELPHI_BUILD_SYSTEM_FPCMAKE build_system_lazbuild = build_system == Constants.DELPHI_BUILD_SYSTEM_LAZBUILD self.label_build_system_title.setVisible(compile_from_source) self.label_build_system.setVisible(compile_from_source) self.label_build_system.setText(Constants.delphi_build_system_display_names[build_system]) # working directory self.label_working_directory_title.setVisible(show_advanced_options) self.label_working_directory.setVisible(show_advanced_options) self.label_working_directory.setText(self.program.working_directory) # make options self.label_make_options_title.setVisible(compile_from_source and show_advanced_options and build_system_fpcmake) self.label_make_options.setVisible(compile_from_source and show_advanced_options and build_system_fpcmake) self.label_make_options.setText('\n'.join(self.program.cast_custom_option_value_list('delphi.make_options', unicode, []))) # lazbuild options self.label_lazbuild_options_title.setVisible(compile_from_source and show_advanced_options and build_system_lazbuild) self.label_lazbuild_options.setVisible(compile_from_source and show_advanced_options and build_system_lazbuild) self.label_lazbuild_options.setText('\n'.join(self.program.cast_custom_option_value_list('delphi.lazbuild_options', unicode, [])))
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, [])))
def update_ui_state(self): show_class_path = self.check_show_class_path.isChecked() show_advanced_options = self.check_show_advanced_options.isChecked() # version def cb_java_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('java', cb_java_versions) # start mode start_mode_api_name = self.program.cast_custom_option_value( 'java.start_mode', str, '<unknown>') start_mode = Constants.get_java_start_mode(start_mode_api_name) start_mode_main_class = start_mode == Constants.JAVA_START_MODE_MAIN_CLASS start_mode_jar_file = start_mode == Constants.JAVA_START_MODE_JAR_FILE self.label_start_mode.setText( Constants.java_start_mode_display_names[start_mode]) # main class self.label_main_class_title.setVisible(start_mode_main_class) self.label_main_class.setVisible(start_mode_main_class) self.label_main_class.setText( self.program.cast_custom_option_value('java.main_class', str, '<unknown>')) # jar file self.label_jar_file_title.setVisible(start_mode_jar_file) self.label_jar_file.setVisible(start_mode_jar_file) self.label_jar_file.setText( self.program.cast_custom_option_value('java.jar_file', str, '<unknown>')) # class path self.label_class_path_title.setVisible(show_class_path) self.label_class_path.setVisible(show_class_path) self.label_class_path.setText('\n'.join( self.program.cast_custom_option_value_list('java.class_path', str, []))) # working directory self.label_working_directory_title.setVisible(show_advanced_options) self.label_working_directory.setVisible(show_advanced_options) self.label_working_directory.setText(self.program.working_directory) # options self.label_options_title.setVisible(show_advanced_options) self.label_options.setVisible(show_advanced_options) self.label_options.setText('\n'.join( self.program.cast_custom_option_value_list('java.options', str, [])))
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, [])))
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()
def update_ui_state(self): show_advanced_options = self.check_show_advanced_options.isChecked() # version def cb_php_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("php", cb_php_versions) # start mode start_mode_api_name = self.program.cast_custom_option_value("php.start_mode", unicode, "<unknown>") start_mode = Constants.get_php_start_mode(start_mode_api_name) start_mode_script_file = start_mode == Constants.PHP_START_MODE_SCRIPT_FILE start_mode_command = start_mode == Constants.PHP_START_MODE_COMMAND start_mode_web_interface = start_mode == Constants.PHP_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.php_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("php.script_file", 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("php.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("php.options", unicode, [])))
def update_ui_state(self): show_class_path = self.check_show_class_path.isChecked() show_advanced_options = self.check_show_advanced_options.isChecked() # version def cb_java_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('java', cb_java_versions) # start mode start_mode_api_name = self.program.cast_custom_option_value('java.start_mode', str, '<unknown>') start_mode = Constants.get_java_start_mode(start_mode_api_name) start_mode_main_class = start_mode == Constants.JAVA_START_MODE_MAIN_CLASS start_mode_jar_file = start_mode == Constants.JAVA_START_MODE_JAR_FILE self.label_start_mode.setText(Constants.java_start_mode_display_names[start_mode]) # main class self.label_main_class_title.setVisible(start_mode_main_class) self.label_main_class.setVisible(start_mode_main_class) self.label_main_class.setText(self.program.cast_custom_option_value('java.main_class', str, '<unknown>')) # jar file self.label_jar_file_title.setVisible(start_mode_jar_file) self.label_jar_file.setVisible(start_mode_jar_file) self.label_jar_file.setText(self.program.cast_custom_option_value('java.jar_file', str, '<unknown>')) # class path self.label_class_path_title.setVisible(show_class_path) self.label_class_path.setVisible(show_class_path) self.label_class_path.setText('\n'.join(self.program.cast_custom_option_value_list('java.class_path', str, []))) # working directory self.label_working_directory_title.setVisible(show_advanced_options) self.label_working_directory.setVisible(show_advanced_options) self.label_working_directory.setText(self.program.working_directory) # options self.label_options_title.setVisible(show_advanced_options) self.label_options.setVisible(show_advanced_options) self.label_options.setText('\n'.join(self.program.cast_custom_option_value_list('java.options', str, [])))
def initializePage(self): self.set_formatted_sub_title( 'Specify how the {language} program [{name}] should be executed.') self.update_combo_version('shell', self.combo_version) self.combo_start_mode.setCurrentIndex( Constants.DEFAULT_SHELL_START_MODE) self.combo_script_file_selector.reset() 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( 'shell.start_mode', str, '<unknown>') start_mode = Constants.get_shell_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('shell.script_file', str, '')) # command self.edit_command.setText( program.cast_custom_option_value('shell.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( 'shell.options', str, []): self.option_list_editor.add_item(option) self.update_ui_state()
def update_ui_state(self): show_advanced_options = self.check_show_advanced_options.isChecked() self.label_working_directory_title.setVisible(show_advanced_options) self.label_working_directory.setVisible(show_advanced_options) self.label_options_title.setVisible(show_advanced_options) self.label_options.setVisible(show_advanced_options) # version def cb_ruby_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('ruby', cb_ruby_versions) # start mode start_mode_api_name = self.program.cast_custom_option_value('ruby.start_mode', unicode, '<unknown>') start_mode = Constants.get_ruby_start_mode(start_mode_api_name) start_mode_script_file = start_mode == Constants.RUBY_START_MODE_SCRIPT_FILE start_mode_command = start_mode == Constants.RUBY_START_MODE_COMMAND self.label_start_mode.setText(Constants.ruby_start_mode_display_names[start_mode]) self.label_script_file_title.setVisible(start_mode_script_file) self.label_script_file.setVisible(start_mode_script_file) self.label_command_title.setVisible(start_mode_command) self.label_command.setVisible(start_mode_command) # script file self.label_script_file.setText(self.program.cast_custom_option_value('ruby.script_file', unicode, '<unknown>')) # command self.label_command.setText(self.program.cast_custom_option_value('ruby.command', unicode, '<unknown>')) # working directory self.label_working_directory.setText(self.program.working_directory) # options self.label_options.setText('\n'.join(self.program.cast_custom_option_value_list('ruby.options', unicode, [])))
def initializePage(self): self.set_formatted_sub_title('Specify how the {language} program [{name}] should be executed.') self.update_combo_version('octave', self.combo_version) self.combo_start_mode.setCurrentIndex(Constants.DEFAULT_OCTAVE_START_MODE) self.combo_script_file_selector.reset() self.check_show_advanced_options.setChecked(False) self.combo_working_directory_selector.reset() self.option_list_editor.reset() self.option_list_editor.add_item('--silent') # FIXME: check if X11 service is enabled instead self.is_full_image = self.wizard().image_version.flavor == 'full' if not self.is_full_image: self.option_list_editor.add_item('--no-window-system') # 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('octave.start_mode', str, '<unknown>') start_mode = Constants.get_octave_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('octave.script_file', 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('octave.options', str, []): self.option_list_editor.add_item(option) self.update_ui_state()
def update_ui_state(self): show_advanced_options = self.check_show_advanced_options.isChecked() compile_from_source = self.program.cast_custom_option_value( 'c.compile_from_source', bool, False) # start mode start_mode_api_name = self.program.cast_custom_option_value( 'c.start_mode', str, '<unknown>') start_mode = Constants.get_c_start_mode(start_mode_api_name) start_mode_executable = start_mode == Constants.C_START_MODE_EXECUTABLE self.label_start_mode.setText( Constants.c_start_mode_display_names[start_mode]) # executable self.label_executable_title.setVisible(start_mode_executable) self.label_executable.setVisible(start_mode_executable) self.label_executable.setText( self.program.cast_custom_option_value('c.executable', str, '')) # compile from source if compile_from_source: self.label_compile_from_source.setText('Enabled') else: self.label_compile_from_source.setText('Disabled') # working directory self.label_working_directory_title.setVisible(show_advanced_options) self.label_working_directory.setVisible(show_advanced_options) self.label_working_directory.setText(self.program.working_directory) # make options self.label_make_options_title.setVisible(compile_from_source and show_advanced_options) self.label_make_options.setVisible(compile_from_source and show_advanced_options) self.label_make_options.setText('\n'.join( self.program.cast_custom_option_value_list('c.make_options', str, [])))
def initializePage(self): self.set_formatted_sub_title( 'Specify how the {language} program [{name}] should be executed.') def cb_nodejs_versions(versions): if versions[0].version != None: node_version_str = ' ' + versions[0].version else: node_version_str = '' self.combo_flavor.clear() self.combo_flavor.addItem('Client-Side (Browser)', '/bin/false') self.combo_flavor.addItem( 'Server-Side (Node.js{0})'.format(node_version_str), versions[0].executable) # if a program exists then this page is used in an edit wizard if self.wizard().program != None: program = self.wizard().program flavor_api_name = program.cast_custom_option_value( 'javascript.flavor', str, '<unknown>') flavor = Constants.get_javascript_flavor(flavor_api_name) if flavor == Constants.JAVASCRIPT_FLAVOR_BROWSER: executable = '/bin/false' else: executable = program.executable set_current_combo_index_from_data(self.combo_flavor, executable) self.combo_flavor.setEnabled(True) self.completeChanged.emit() self.get_executable_versions('nodejs', cb_nodejs_versions) self.combo_start_mode.setCurrentIndex( Constants.DEFAULT_JAVASCRIPT_START_MODE) self.combo_script_file_selector.reset() 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( 'javascript.start_mode', str, '<unknown>') start_mode = Constants.get_javascript_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('javascript.script_file', str, '')) # command self.edit_command.setText( program.cast_custom_option_value('javascript.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( 'javascript.options', str, []): self.option_list_editor.add_item(option) self.update_ui_state()
def initializePage(self): self.set_formatted_sub_title( 'Specify how the {language} program [{name}] should be executed.') def cb_gcc_versions(versions): if versions[0].version != None: gcc = '<b>{0}</b> ({1})'.format(versions[0].executable, versions[0].version) else: gcc = '<b>{0}</b>'.format(versions[0].executable) if versions[1].version != None: gpp = '<b>{0}</b> ({1})'.format(versions[1].executable, versions[1].version) else: gpp = '<b>{0}</b>'.format(versions[1].executable) self.label_compile_from_source_help_new.setText( self.compile_from_source_help_new_template.replace( '<GCC>', gcc).replace('<G++>', gpp)) self.label_compile_from_source_help_edit.setText( self.compile_from_source_help_edit_template.replace( '<GCC>', gcc).replace('<G++>', gpp)) self.get_executable_versions('gcc', cb_gcc_versions) self.combo_start_mode.setCurrentIndex(Constants.DEFAULT_C_START_MODE) self.check_compile_from_source.setChecked(False) self.check_show_advanced_options.setChecked(False) self.combo_working_directory_selector.reset() self.make_option_list_editor.reset() # if a program exists then this page is used in an edit wizard if self.wizard().program != None: program = self.wizard().program self.edit_mode = True # start mode start_mode_api_name = program.cast_custom_option_value( 'c.start_mode', str, '<unknown>') start_mode = Constants.get_c_start_mode(start_mode_api_name) self.combo_start_mode.setCurrentIndex(start_mode) # executable self.edit_executable.setText( program.cast_custom_option_value('c.executable', str, '')) # compile from source self.check_compile_from_source.setChecked( program.cast_custom_option_value('c.compile_from_source', bool, False)) # working directory self.combo_working_directory_selector.set_current_text( program.working_directory) # make options self.make_option_list_editor.clear() for make_option in program.cast_custom_option_value_list( 'c.make_options', str, []): self.make_option_list_editor.add_item(make_option) self.update_ui_state()
def refresh_async(): try: a = tarfile.open(filename, 'r:gz') except Exception as e: return [], 'Could not open archive:\n\n{0}'.format(e) with contextlib.closing(a): try: v = a.extractfile('tfrba-version') except Exception as e: return [], 'Could not extract tfrba-version:\n\n{0}'.format(e) version = v.read() v.close() if version != b'1': return [], 'Unknown tfrba-version {0}'.format(version) programs = {} for member in a.getnames(): if member.startswith('programs/') and member.endswith('/program.conf'): try: c = a.extractfile(member) except Exception as e: return [], 'Could not extract {0}:\n\n{1}'.format(member, e) conf = list(map(lambda line: line.decode('utf-8'), c.readlines())) c.close() name = '<unknown>' identifier = member.split('/')[1] language = '<unknown>' first_upload = 0 for line in conf: if line.startswith('custom.name ='): try: name = line[len('custom.name ='):].strip().encode('ascii').decode('unicode_escape') except: pass elif line.startswith('custom.language ='): try: language = Constants.get_language_display_name(line[len('custom.language ='):].strip().encode('ascii').decode('unicode_escape')) except: pass elif line.startswith('custom.first_upload ='): try: first_upload = int(line[len('custom.first_upload ='):].strip()) except: pass programs[identifier] = [name, identifier, language, 'New', first_upload] try: existing_programs = get_lite_programs(self.session) except Exception as e: return [], 'Could not get existing program list:\n\n{0}'.format(e) for existing_program in existing_programs: identifier = existing_program.identifier if identifier in programs: programs[identifier][3] = 'Existing' return programs.values(), None
def initializePage(self): self.set_formatted_sub_title( 'Specify how the {language} program [{name}] should be executed.') self.update_combo_version('java', self.combo_version) self.combo_start_mode.setCurrentIndex( Constants.DEFAULT_JAVA_START_MODE) self.combo_jar_file_selector.reset() self.class_path_list_editor.reset() self.check_show_class_path.setChecked(False) 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: self.bin_directory = posixpath.join(program.root_directory, 'bin') else: identifier = self.get_field('identifier') self.bin_directory = posixpath.join('/', 'home', 'tf', 'programs', identifier, 'bin') # collect class path entries self.class_path_candidates = ['.'] for filename in sorted(self.wizard().available_files): directroy = posixpath.split(filename)[0] if len(directroy ) > 0 and directroy not in self.class_path_candidates: self.class_path_candidates.append(directroy) if filename.endswith('.class') or filename.endswith('.properties'): if program == None: self.class_path_list_editor.add_item(directroy) elif filename.endswith('.jar'): self.class_path_candidates.append(filename) if program == None: self.class_path_list_editor.add_item(filename) self.class_path_list_editor.add_item( '/usr/tinkerforge/bindings/java/Tinkerforge.jar') self.class_path_candidates.append( '/usr/tinkerforge/bindings/java/Tinkerforge.jar') self.combo_main_class.clear() self.combo_main_class.clearEditText() # collect main classes if program != None: self.combo_main_class.setEnabled(False) def get_main_classes(): script_instance_ref = [None] def progress_canceled(): script_instance = script_instance_ref[0] if script_instance == None: return self.wizard().script_manager.abort_script(script_instance) progress = ExpandingProgressDialog(self.wizard()) progress.set_progress_text_visible(False) progress.setWindowTitle('Edit Program') progress.setLabelText('Collecting Java main classes') progress.setModal(True) progress.setRange(0, 0) progress.canceled.connect(progress_canceled) progress.show() def cb_java_main_classes(result): script_instance = script_instance_ref[0] if script_instance != None: aborted = script_instance.abort else: aborted = False script_instance_ref[0] = None def done(): progress.cancel() self.combo_main_class.setEnabled(True) self.completeChanged.emit() if aborted: done() return okay, message = check_script_result(result, decode_stderr=True) if not okay: self.label_main_class_error.setText( '<b>Error:</b> ' + html.escape(message)) self.label_main_class_error.setVisible(True) done() return def expand_async(data): try: main_classes = json.loads( zlib.decompress( memoryview(data)).decode('utf-8')) if not isinstance(main_classes, dict): main_classes = {} except: main_classes = {} return main_classes def cb_expand_success(main_classes): self.combo_main_class.clear() for cls in sorted(main_classes.keys()): self.combo_main_class.addItem( cls, main_classes[cls]) self.combo_main_class_checker.set_current_text( program.cast_custom_option_value( 'java.main_class', str, '')) done() def cb_expand_error(): self.label_main_class_error.setText( '<b>Error:</b> Internal async error') self.label_main_class_error.setVisible(True) done() async_call(expand_async, result.stdout, cb_expand_success, cb_expand_error) script_instance_ref[0] = self.wizard( ).script_manager.execute_script('java_main_classes', cb_java_main_classes, [self.bin_directory], max_length=1024 * 1024, decode_output_as_utf8=False) # need to decouple this with a timer, otherwise it's executed at # a time where the progress bar cannot properly enter model state # to block the parent widget QTimer.singleShot(0, get_main_classes) elif self.wizard().hasVisitedPage(Constants.PAGE_FILES): uploads = self.wizard().page(Constants.PAGE_FILES).get_uploads() if len(uploads) > 0: abort_ref = [False] def progress_canceled(): abort_ref[0] = True progress = ExpandingProgressDialog(self) progress.set_progress_text_visible(False) progress.setWindowTitle('New Program') progress.setLabelText('Collecting Java main classes') progress.setModal(True) progress.setRange(0, 0) progress.canceled.connect(progress_canceled) progress.show() def cb_main_classes(main_classes): for main_class in main_classes: self.combo_main_class.addItem(main_class) if self.combo_main_class.count() > 1: self.combo_main_class.clearEditText() progress.cancel() self.combo_main_class.setEnabled(True) self.completeChanged.emit() def cb_main_classes_error(): self.label_main_class_error.setText( '<b>Error:</b> Internal async error') self.label_main_class_error.setVisible(True) progress.cancel() self.combo_main_class.clearEditText() self.combo_main_class.setEnabled(True) self.completeChanged.emit() def get_main_classes_async(uploads): return sorted( get_main_classes_from_class_or_jar(uploads, abort_ref)) self.combo_main_class.setEnabled(False) async_call(get_main_classes_async, uploads, cb_main_classes, cb_main_classes_error) # if a program exists then this page is used in an edit wizard if program != None: # start mode start_mode_api_name = program.cast_custom_option_value( 'java.start_mode', str, '<unknown>') start_mode = Constants.get_java_start_mode(start_mode_api_name) self.combo_start_mode.setCurrentIndex(start_mode) # main class self.combo_main_class_checker.set_current_text( program.cast_custom_option_value('java.main_class', str, '')) # jar file self.combo_jar_file_selector.set_current_text( program.cast_custom_option_value('java.jar_file', str, '')) # class path self.class_path_list_editor.clear() for class_path_entry in program.cast_custom_option_value_list( 'java.class_path', str, []): self.class_path_list_editor.add_item(class_path_entry) # 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( 'java.options', str, []): self.option_list_editor.add_item(option) self.update_ui_state()
def initializePage(self): self.set_formatted_sub_title( 'Specify how the {language} program [{name}] should be executed.') def cb_fpc_versions(versions): if versions[0].version != None: fpc = '<b>{0}</b> ({1})'.format(versions[0].executable, versions[0].version) else: fpc = '<b>{0}</b>'.format(versions[0].executable) self.label_build_system_fpcmake_help.setText( self.build_system_fpcmake_help_template.replace('<FPC>', fpc)) self.get_executable_versions('fpc', cb_fpc_versions) def cb_lazbuild_versions(versions): if versions[0].version != None: lazbuild = '<b>{0}</b> ({1})'.format(versions[0].executable, versions[0].version) self.lazbuild_available = True self.combo_build_system.setItemText(1, 'lazbuild') else: lazbuild = '<b>{0}</b>'.format(versions[0].executable) self.label_build_system_lazbuild_help.setText( self.build_system_lazbuild_help_template.replace( '<LAZBUILD>', lazbuild)) self.get_executable_versions('lazbuild', cb_lazbuild_versions) self.combo_start_mode.setCurrentIndex( Constants.DEFAULT_DELPHI_START_MODE) self.check_compile_from_source.setChecked(False) self.check_show_advanced_options.setChecked(False) self.combo_working_directory_selector.reset() self.make_option_list_editor.reset() self.lazbuild_option_list_editor.reset() # if a program exists then this page is used in an edit wizard if self.wizard().program != None: program = self.wizard().program self.edit_mode = True # start mode start_mode_api_name = program.cast_custom_option_value( 'delphi.start_mode', str, '<unknown>') start_mode = Constants.get_delphi_start_mode(start_mode_api_name) self.combo_start_mode.setCurrentIndex(start_mode) # executable self.edit_executable.setText( program.cast_custom_option_value('delphi.executable', str, '')) # compile from source self.check_compile_from_source.setChecked( program.cast_custom_option_value('delphi.compile_from_source', bool, False)) # build system build_system_api_name = program.cast_custom_option_value( 'delphi.build_system', str, '<unknown>') build_system = Constants.get_delphi_build_system( build_system_api_name) self.combo_build_system.setCurrentIndex(build_system) # working directory self.combo_working_directory_selector.set_current_text( program.working_directory) # make options self.make_option_list_editor.clear() for make_option in program.cast_custom_option_value_list( 'delphi.make_options', str, []): self.make_option_list_editor.add_item(make_option) # lazbuild options self.lazbuild_option_list_editor.clear() for lazbuild_option in program.cast_custom_option_value_list( 'delphi.lazbuild_options', str, []): self.lazbuild_option_list_editor.add_item(lazbuild_option) self.update_ui_state()
def refresh_async(): try: a = tarfile.open(filename, 'r:gz') except Exception as e: return [], 'Could not open archive:\n\n{0}'.format(e) with contextlib.closing(a): try: v = a.extractfile('tfrba-version') except Exception as e: return [], 'Could not extract tfrba-version:\n\n{0}'.format( e) version = v.read() v.close() if version != b'1': return [], 'Unknown tfrba-version {0}'.format(version) programs = {} for member in a.getnames(): if member.startswith('programs/') and member.endswith( '/program.conf'): try: c = a.extractfile(member) except Exception as e: return [], 'Could not extract {0}:\n\n{1}'.format( member, e) conf = list( map(lambda line: line.decode('utf-8'), c.readlines())) c.close() name = '<unknown>' identifier = member.split('/')[1] language = '<unknown>' first_upload = 0 for line in conf: if line.startswith('custom.name ='): try: name = line[len('custom.name ='):].strip( ).encode('ascii').decode('unicode_escape') except: pass elif line.startswith('custom.language ='): try: language = Constants.get_language_display_name( line[len('custom.language ='):].strip( ).encode('ascii').decode( 'unicode_escape')) except: pass elif line.startswith('custom.first_upload ='): try: first_upload = int( line[len('custom.first_upload =' ):].strip()) except: pass programs[identifier] = [ name, identifier, language, 'New', first_upload ] try: existing_programs = get_lite_programs(self.session) except Exception as e: return [], 'Could not get existing program list:\n\n{0}'.format( e) for existing_program in existing_programs: identifier = existing_program.identifier if identifier in programs: programs[identifier][3] = 'Existing' return programs.values(), None