def make_linter_command(cobol_file_name, original_file_path): from .settings import Settings settings = Settings() args = ['-fsyntax-only', '-I%s' % os.path.dirname(original_file_path)] args.append('-std=%s' % str(settings.cobol_standard).replace('GnuCobolStandard.', '')) args += settings.compiler_flags original_path = os.path.dirname(original_file_path) if settings.free_format: args.append('-free') if settings.copybook_paths: for pth in settings.copybook_paths.split(';'): if not pth: continue if not os.path.isabs(pth): # expand relative path based on the original source path # See github issue #119 pth = os.path.abspath(os.path.join(original_path, pth)) args.append('-I%s' % pth) if settings.library_search_path: for pth in settings.library_search_path.split(';'): if pth: args.append('-L%s' % pth) if settings.libraries: for lib in system.shell_split(settings.libraries): if lib: args.append('-l%s' % lib) args.append(cobol_file_name) pgm = Settings().full_compiler_path return pgm, args
def _run_in_external_terminal(self, program, wd, file_type): """ Runs a program in an external terminal. :param program: program to run :param wd: working directory """ self.ui.consoleOutput.append( "Launched in external terminal") pyqode_console = system.which('pyqode-console') if file_type == FileType.MODULE: program = QtCore.QFileInfo(program).baseName() if system.windows: cmd = [pyqode_console, program] if file_type == FileType.MODULE: cmd.insert(1, system.which('cobcrun')) subprocess.Popen(cmd, cwd=wd, creationflags=subprocess.CREATE_NEW_CONSOLE) elif system.darwin: cmd = ['open', program] if file_type == FileType.MODULE: cmd.insert(1, system.which('cobcrun')) subprocess.Popen(cmd, cwd=wd) else: if file_type == FileType.EXECUTABLE: cmd = ['"%s %s"' % (pyqode_console, program)] else: cmd = ['"%s %s %s"' % (pyqode_console, system.which('cobcrun'), program)] cmd = system.shell_split( Settings().external_terminal_command.strip()) + cmd subprocess.Popen(' '.join(cmd), cwd=wd, shell=True) _logger().info('running program in external terminal: %s', ' '.join(cmd))
def make_linter_command(cobol_file_name, original_file_path): from .settings import Settings settings = Settings() args = ['-fsyntax-only', '-I%s' % os.path.dirname(original_file_path)] args.append('-std=%s' % str(settings.cobol_standard).replace( 'GnuCobolStandard.', '')) args += settings.compiler_flags original_path = os.path.dirname(original_file_path) if settings.free_format: args.append('-free') if settings.copybook_paths: for pth in settings.copybook_paths.split(';'): if not pth: continue if not os.path.isabs(pth): # expand relative path based on the original source path # See github issue #119 pth = os.path.abspath(os.path.join(original_path, pth)) args.append('-I%s' % pth) if settings.library_search_path: for pth in settings.library_search_path.split(';'): if pth: args.append('-L%s' % pth) if settings.libraries: for lib in system.shell_split(settings.libraries): if lib: args.append('-l%s' % lib) args.append(cobol_file_name) pgm = Settings().compiler_path return pgm, args
def make_command(self, input_file_names, file_type, output_dir=None, additional_options=None): """ Makes the command needed to compile the specified file. :param input_file_names: Input file names (without path). The first name must be the source file, other entries can be used to link with additional object files. :param output_file_name: Output file base name (without path and extension). None to use the input_file_name base name. :param file_type: file type (exe or dll). :return: a tuple made up of the program name and the command arguments. """ from .settings import Settings settings = Settings() output_file_name = self.get_output_filename(input_file_names, file_type) options = [] if file_type == FileType.EXECUTABLE: options.append('-x') options.append('-o') options.append(os.path.join(output_dir, output_file_name)) if GnuCobolStandard(settings.cobol_standard) != GnuCobolStandard.none: options.append( '-std=%s' % str(settings.cobol_standard).replace('GnuCobolStandard.', '')) options += settings.compiler_flags if settings.free_format: options.append('-free') if settings.copybook_paths: for pth in settings.copybook_paths.split(';'): if not pth: continue options.append('-I%s' % pth) if settings.library_search_path: for pth in settings.library_search_path.split(';'): if pth: options.append('-L%s' % pth) if settings.libraries: for lib in system.shell_split(settings.libraries): if lib: options.append('-l%s' % lib) if additional_options: options += additional_options for ifn in input_file_names: if system.windows and ' ' in ifn: ifn = '"%s"' % ifn options.append(ifn) pgm = Settings().compiler_path return pgm, options
def make_command(self, input_file_names, file_type, output_dir=None, additional_options=None): """ Makes the command needed to compile the specified file. :param input_file_names: Input file names (without path). The first name must be the source file, other entries can be used to link with additional object files. :param output_file_name: Output file base name (without path and extension). None to use the input_file_name base name. :param file_type: file type (exe or dll). :return: a tuple made up of the program name and the command arguments. """ from .settings import Settings settings = Settings() output_file_name = self.get_output_filename( input_file_names, file_type) options = [] if file_type == FileType.EXECUTABLE: options.append('-x') options.append('-o') options.append(os.path.join(output_dir, output_file_name)) if GnuCobolStandard(settings.cobol_standard) != GnuCobolStandard.none: options.append('-std=%s' % str(settings.cobol_standard).replace( 'GnuCobolStandard.', '')) options += settings.compiler_flags if settings.free_format: options.append('-free') if settings.copybook_paths: for pth in settings.copybook_paths.split(';'): if not pth: continue options.append('-I%s' % pth) if settings.library_search_path: for pth in settings.library_search_path.split(';'): if pth: options.append('-L%s' % pth) if settings.libraries: for lib in system.shell_split(settings.libraries): if lib: options.append('-l%s' % lib) if additional_options: options += additional_options for ifn in input_file_names: if system.windows and ' ' in ifn: ifn = '"%s"' % ifn options.append(ifn) pgm = Settings().compiler_path return pgm, options
def _run_in_external_terminal(self, program, wd, file_type): """ Runs a program in an external terminal. :param program: program to run :param wd: working directory """ self.ui.consoleOutput.append("Launched in external terminal") pyqode_console = system.which('pyqode-console') if file_type == FileType.MODULE: program = QtCore.QFileInfo(program).baseName() if system.windows: cmd = [pyqode_console, program] if file_type == FileType.MODULE: cmd.insert(1, system.which('cobcrun')) subprocess.Popen(cmd, cwd=wd, creationflags=subprocess.CREATE_NEW_CONSOLE) elif system.darwin: cmd = ['open', program] if file_type == FileType.MODULE: cmd.insert(1, system.which('cobcrun')) subprocess.Popen(cmd, cwd=wd) else: if file_type == FileType.EXECUTABLE: cmd = ['"%s %s"' % (pyqode_console, program)] else: cmd = [ '"%s %s %s"' % (pyqode_console, system.which('cobcrun'), program) ] cmd = system.shell_split( Settings().external_terminal_command.strip()) + cmd subprocess.Popen(' '.join(cmd), cwd=wd, shell=True) _logger().info('running program in external terminal: %s', ' '.join(cmd))
def apply(self): # force next check (otherwise the cached result will be used) compilers.GnuCobolCompiler.check_compiler.reset() settings = Settings() settings.show_cursor_pos_in_bytes = \ self.cb_cursor_pos_in_bytes.isChecked() settings.display_lines = self.checkBoxViewLineNumber.isChecked() settings.highlight_caret = self.checkBoxHighlightCurrentLine.isChecked( ) settings.show_whitespaces = \ self.checkBoxHighlightWhitespaces.isChecked() settings.tab_len = self.spinBoxEditorTabLen.value() settings.enable_autoindent = self.checkBoxEditorAutoIndent.isChecked() settings.code_completion_trigger_len = \ self.spinBoxEditorCCTriggerLen.value() settings.preferred_eol = self.comboBoxPreferredEOL.currentIndex() settings.autodetect_eol = self.checkBoxAutodetectEOL.isChecked() settings.dark_style = self.radioButtonColorDark.isChecked() settings.font = self.fontComboBox.currentFont().family() settings.font_size = self.spinBoxFontSize.value() settings.color_scheme = self.listWidgetColorSchemes.currentItem().text( ) settings.external_terminal = self.checkBoxRunExtTerm.isChecked() settings.external_terminal_command = self.lineEditRunTerm.text() settings.lower_case_keywords = self.rbLowerCaseKwds.isChecked() settings.compiler_path = self.lineEditCompilerPath.text() settings.vcvarsall = self.lineEditVCVARS.text() settings.vcvarsall_arch = self.combo_arch.currentText() settings.path = self.PATH.text() settings.path_enabled = self.cbPATH.isChecked() settings.cob_config_dir = self.COB_CONFIG_DIR.text() settings.cob_config_dir_enabled = self.cbCOB_CONFIG_DIR.isChecked() settings.cob_copy_dir = self.COB_COPY_DIR.text() settings.cob_copy_dir_enabled = self.cbCOB_COPY_DIR.isChecked() settings.cob_include_path = self.COB_INCLUDE_PATH.text() settings.cob_include_path_enabled = self.cbCOB_INCLUDE_PATH.isChecked() settings.cob_lib_path = self.COB_LIB_PATH.text() settings.cob_lib_path_enabled = self.cbCOB_LIB_PATH.isChecked() settings.free_format = self.checkBoxFreeFormat.isChecked() settings.comment_indicator = self.lineEditCommentIndicator.text() settings.autodetect_submodules = \ self.cbAutoDetectSublmodules.isChecked() settings.cobol_standard = GnuCobolStandard( self.comboBoxStandard.currentIndex()) settings.icon_theme = self.comboBoxIconTheme.currentText() settings.show_errors = self.checkBoxShowErrors.isChecked() settings.enable_smart_backspace = \ self.checkBoxSmartBackspace.isChecked() paths = [] for i in range(self.listWidgetLibPaths.count()): paths.append(self.listWidgetLibPaths.item(i).text()) settings.library_search_path = ';'.join(paths) paths = [] for i in range(self.listWidgetCopyPaths.count()): paths.append(self.listWidgetCopyPaths.item(i).text()) settings.copybook_paths = ';'.join(paths) settings.libraries = self.lineEditLibs.text() settings.output_directory = self.lineEditOutputDirectory.text() settings.copy_runtime_dlls = self.cb_copy_runtime_dlls.isChecked() cb_flags = [ self.cb_g, self.cb_ftrace, self.cb_ftraceall, self.cb_debugging_line, self.cb_static, self.cb_debug, self.cb_w, self.cb_wall ] flags = [cb.text() for cb in cb_flags if cb.isChecked()] flags += system.shell_split(self.le_compiler_flags.text()) settings.compiler_flags = flags # sql settings.dbpre = self.lineEditDbpre.text() settings.dbpre_framework = self.lineEditDbpreFramework.text() settings.cobmysqlapi = self.lineEditCobmysqlapi.text() settings.dbhost = self.lineEditDBHOST.text() settings.dbuser = self.lineEditDBUSER.text() settings.dbpasswd = self.lineEditDBPASSWD.text() settings.dbname = self.lineEditDBNAME.text() settings.dbport = self.lineEditDBPORT.text() settings.dbsocket = self.lineEditDBSOCKET.text() settings.esqloc = self.lineEditESQLOC.text() settings.completion_filter_mode = \ self.comboCcFilterMode.currentIndex() settings.cobc_extensions = [ ext.lower() for ext in self.lineEditCobcExts.text().split(';') if ext ] settings.dbpre_extensions = [ ext.lower() for ext in self.lineEditDbpreExts.text().split(';') if ext ] settings.esqloc_extensions = [ ext for ext in self.lineEditesqlOcExts.text().split(';') if ext ] colors = [] positions = [] for spin_box, picker in zip(self._margin_spin_boxes, self._margin_color_pickers): positions.append(spin_box.value() - 1) colors.append(picker.color.name()) settings.margin_positions = positions settings.margin_colors = colors env = {} for i in range(self.tw_run_env.rowCount()): env[self.tw_run_env.item(i, 0).text()] = self.tw_run_env.item( i, 1).text() settings.run_environemnt = env settings.working_dir = self.edit_working_dir.text()
def _run_in_external_terminal(self, program, wd, file_type): """ Runs a program in an external terminal. :param program: program to run :param wd: working directory """ pyqode_console = system.which('pyqode-console') cobc_run_insert_pos = 1 if pyqode_console is None: from pyqode.core.tools import console pyqode_console = [sys.executable, console.__file__] cobc_run_insert_pos = 2 else: pyqode_console = [pyqode_console] env = os.environ.copy() for k, v in list(Settings().run_environemnt.items()): env[k] = v if 'PATH' not in list(Settings().run_environemnt.keys()): env['PATH'] = GnuCobolCompiler.setup_process_environment().value( 'PATH') if file_type == FileType.MODULE: program = QtCore.QFileInfo(program).baseName() if system.windows: cmd = pyqode_console + [program] if file_type == FileType.MODULE: cmd.insert(cobc_run_insert_pos, system.which('cobcrun')) try: _logger().debug( "running program in external terminal: %r, %r, %r" % (cmd, wd, env)) subprocess.Popen(cmd, cwd=wd, creationflags=subprocess.CREATE_NEW_CONSOLE, env=env) except (OSError, subprocess.CalledProcessError): msg = "Failed to launch program in external terminal (cmd=%s) " % ' '.join( cmd) _logger().exception(msg) self.ui.consoleOutput.appendPlainText(msg) return elif system.darwin: if file_type == FileType.MODULE: create_script(PATH_RUN_MODULE_SCRIPT, RUN_MODULE_SCRIPT, (wd, system.which('cobcrun'), program)) cmd = [ 'open', '-n', '-a', 'Terminal', '--args', PATH_RUN_MODULE_SCRIPT ] else: create_script(PATH_RUN_PROGRAM_SCRIPT, RUN_PROGRAM_SCRIPT, (wd, program)) cmd = [ 'open', '-n', '-a', 'Terminal', '--args', PATH_RUN_PROGRAM_SCRIPT ] try: subprocess.Popen(cmd, cwd=wd, env=env) except (OSError, subprocess.CalledProcessError): msg = "Failed to launch program in external terminal (cmd=%s) " % ' '.join( cmd) _logger().exception(msg) self.ui.consoleOutput.appendPlainText(msg) return else: if file_type == FileType.EXECUTABLE: cmd = ['"%s %s"' % (' '.join(pyqode_console), program)] else: cmd = [ '"%s %s %s"' % (' '.join(pyqode_console), system.which('cobcrun'), program) ] cmd = system.shell_split( Settings().external_terminal_command.strip()) + cmd try: subprocess.Popen(' '.join(cmd), cwd=wd, shell=True, env=env) except (OSError, subprocess.CalledProcessError): msg = "Failed to launch program in external terminal (cmd=%s) " % ' '.join( cmd) _logger().exception(msg) self.ui.consoleOutput.appendPlainText(msg) return _logger().info('running program in external terminal: %s', ' '.join(cmd)) self.ui.consoleOutput.appendPlainText( "Launched in external terminal: %s" % ' '.join(cmd))
def _run_in_external_terminal(self, program, wd, file_type): """ Runs a program in an external terminal. :param program: program to run :param wd: working directory """ pyqode_console = system.which('pyqode-console') cobc_run_insert_pos = 1 if pyqode_console is None: from pyqode.core.tools import console pyqode_console = [sys.executable, console.__file__] cobc_run_insert_pos = 2 else: pyqode_console = [pyqode_console] env = os.environ.copy() for k, v in Settings().run_environemnt.items(): env[k] = v if 'PATH' not in Settings().run_environemnt.keys(): env['PATH'] = GnuCobolCompiler.setup_process_environment().value( 'PATH') if file_type == FileType.MODULE: program = QtCore.QFileInfo(program).baseName() if system.windows: cmd = pyqode_console + [program] if file_type == FileType.MODULE: cmd.insert(cobc_run_insert_pos, system.which('cobcrun')) try: _logger().debug("running program in external terminal: %r, %r, %r" % (cmd, wd, env)) subprocess.Popen(cmd, cwd=wd, creationflags=subprocess.CREATE_NEW_CONSOLE, env=env) except (OSError, subprocess.CalledProcessError): msg = "Failed to launch program in external terminal (cmd=%s) " % ' '.join(cmd) _logger().exception(msg) self.ui.consoleOutput.appendPlainText(msg) return elif system.darwin: if file_type == FileType.MODULE: create_script(PATH_RUN_MODULE_SCRIPT, RUN_MODULE_SCRIPT, (wd, system.which('cobcrun'), program)) cmd = ['open', '-n', '-a', 'Terminal', '--args', PATH_RUN_MODULE_SCRIPT] else: create_script(PATH_RUN_PROGRAM_SCRIPT, RUN_PROGRAM_SCRIPT, (wd, program)) cmd = ['open', '-n', '-a', 'Terminal', '--args', PATH_RUN_PROGRAM_SCRIPT] try: subprocess.Popen(cmd, cwd=wd, env=env) except (OSError, subprocess.CalledProcessError): msg = "Failed to launch program in external terminal (cmd=%s) " % ' '.join(cmd) _logger().exception(msg) self.ui.consoleOutput.appendPlainText(msg) return else: if file_type == FileType.EXECUTABLE: cmd = ['"%s %s"' % (' '.join(pyqode_console), program)] else: cmd = ['"%s %s %s"' % (' '.join(pyqode_console), system.which('cobcrun'), program)] cmd = system.shell_split(Settings().external_terminal_command.strip()) + cmd try: subprocess.Popen(' '.join(cmd), cwd=wd, shell=True, env=env) except (OSError, subprocess.CalledProcessError): msg = "Failed to launch program in external terminal (cmd=%s) " % ' '.join(cmd) _logger().exception(msg) self.ui.consoleOutput.appendPlainText(msg) return _logger().info('running program in external terminal: %s', ' '.join(cmd)) self.ui.consoleOutput.appendPlainText("Launched in external terminal: %s" % ' '.join(cmd))
def apply(self): # force next check (otherwise the cached result will be used) compilers.GnuCobolCompiler.check_compiler.reset() settings = Settings() settings.show_cursor_pos_in_bytes = self.cb_cursor_pos_in_bytes.isChecked() settings.display_lines = self.checkBoxViewLineNumber.isChecked() settings.highlight_caret = self.checkBoxHighlightCurrentLine.isChecked() settings.show_whitespaces = self.checkBoxHighlightWhitespaces.isChecked() settings.tab_len = self.spinBoxEditorTabLen.value() settings.enable_autoindent = self.checkBoxEditorAutoIndent.isChecked() settings.code_completion_trigger_len = self.spinBoxEditorCCTriggerLen.value() settings.preferred_eol = self.comboBoxPreferredEOL.currentIndex() settings.autodetect_eol = self.checkBoxAutodetectEOL.isChecked() settings.dark_style = self.radioButtonColorDark.isChecked() settings.font = self.fontComboBox.currentFont().family() settings.font_size = self.spinBoxFontSize.value() settings.color_scheme = self.listWidgetColorSchemes.currentItem().text() settings.external_terminal = self.checkBoxRunExtTerm.isChecked() settings.external_terminal_command = self.lineEditRunTerm.text() settings.lower_case_keywords = self.rbLowerCaseKwds.isChecked() settings.compiler_path = self.lineEditCompilerPath.text() settings.vcvarsall = self.lineEditVCVARS.text() settings.vcvarsall_arch = self.combo_arch.currentText() settings.path = self.PATH.text() settings.path_enabled = self.cbPATH.isChecked() settings.cob_config_dir = self.COB_CONFIG_DIR.text() settings.cob_config_dir_enabled = self.cbCOB_CONFIG_DIR.isChecked() settings.cob_copy_dir = self.COB_COPY_DIR.text() settings.cob_copy_dir_enabled = self.cbCOB_COPY_DIR.isChecked() settings.cob_include_path = self.COB_INCLUDE_PATH.text() settings.cob_include_path_enabled = self.cbCOB_INCLUDE_PATH.isChecked() settings.cob_lib_path = self.COB_LIB_PATH.text() settings.cob_lib_path_enabled = self.cbCOB_LIB_PATH.isChecked() settings.free_format = self.checkBoxFreeFormat.isChecked() settings.comment_indicator = self.lineEditCommentIndicator.text() settings.autodetect_submodules = self.cbAutoDetectSublmodules.isChecked() settings.cobol_standard = GnuCobolStandard(self.comboBoxStandard.currentIndex()) settings.icon_theme = self.comboBoxIconTheme.currentText() settings.show_errors = self.checkBoxShowErrors.isChecked() settings.enable_smart_backspace = self.checkBoxSmartBackspace.isChecked() paths = [] for i in range(self.listWidgetLibPaths.count()): paths.append(self.listWidgetLibPaths.item(i).text()) settings.library_search_path = ";".join(paths) paths = [] for i in range(self.listWidgetCopyPaths.count()): paths.append(self.listWidgetCopyPaths.item(i).text()) settings.copybook_paths = ";".join(paths) settings.libraries = self.lineEditLibs.text() settings.output_directory = self.lineEditOutputDirectory.text() cb_flags = [self.cb_g, self.cb_ftrace, self.cb_ftraceall, self.cb_debugging_line, self.cb_static, self.cb_debug] flags = [cb.text() for cb in cb_flags if cb.isChecked()] flags += system.shell_split(self.le_compiler_flags.text()) settings.compiler_flags = flags # sql settings.dbpre = self.lineEditDbpre.text() settings.dbpre_framework = self.lineEditDbpreFramework.text() settings.cobmysqlapi = self.lineEditCobmysqlapi.text() settings.dbhost = self.lineEditDBHOST.text() settings.dbuser = self.lineEditDBUSER.text() settings.dbpasswd = self.lineEditDBPASSWD.text() settings.dbname = self.lineEditDBNAME.text() settings.dbport = self.lineEditDBPORT.text() settings.dbsocket = self.lineEditDBSOCKET.text() settings.esqloc = self.lineEditESQLOC.text() settings.completion_filter_mode = self.comboCcFilterMode.currentIndex() settings.cobc_extensions = [ext.lower() for ext in self.lineEditCobcExts.text().split(";") if ext] settings.dbpre_extensions = [ext.lower() for ext in self.lineEditDbpreExts.text().split(";") if ext] settings.esqloc_extensions = [ext for ext in self.lineEditesqlOcExts.text().split(";") if ext]