Esempio n. 1
0
    def _check_compiler(self, *_):
        from open_cobol_ide.app import Application

        self.apply()
        Application.init_env()
        pth = self.lineEditCompilerPath.text()
        if os.path.exists(pth):
            p = QtCore.QProcess()
            p.start(pth, ["--version"])
            p.waitForFinished()
            output = bytes(p.readAllStandardOutput()).decode(locale.getpreferredencoding())
            DlgCheckCompiler.check(self, pth, output)
        else:
            QtWidgets.QMessageBox.warning(
                self, "Invalid compiler path", "Not a valid compiler path, path does not exists: %s!" % pth
            )
Esempio n. 2
0
 def _check_compiler(self, *_):
     from open_cobol_ide.app import Application
     self.apply()
     Application.init_env()
     pth = self.lineEditCompilerPath.text()
     if os.path.exists(pth):
         p = QtCore.QProcess()
         p.start(pth, ['--version'])
         p.waitForFinished()
         output = bytes(p.readAllStandardOutput()).decode(
             locale.getpreferredencoding())
         DlgCheckCompiler.check(self, pth, output)
     else:
         QtWidgets.QMessageBox.warning(
             self, 'Invalid compiler path',
             'Not a valid compiler path, path does not exists: %s!' % pth)
Esempio n. 3
0
def lint(request_data):
    """
    Performs linting of a COBOL document.

    This method will perform on the pyqode backend.

    :param request_data: work request data (dict)
    :return: status, messages
    """
    from open_cobol_ide.app import Application
    Application.init_env()
    code = request_data['code']
    path = request_data['path']
    extension = os.path.splitext(path)[1]
    if extension.lower() in settings.Settings().cobc_extensions:
        # code might not have been saved yet, run cobc on a tmp file
        # we use a time stamp to avoid overwriting the file another cobc
        # instance might be compiling.
        file_name = os.path.split(path)[1]
        file_name, ext = os.path.splitext(file_name)
        tmp_name = '%s.%s%s' % (file_name, str(int(time.time())), ext)
        tmp_pth = os.path.join(tempfile.gettempdir(), tmp_name)
        with open(tmp_pth, 'w') as f:
            f.write(code)
        compiler = GnuCobolCompiler()
        pgm, args = make_linter_command(tmp_name, path)
        process = QtCore.QProcess()
        process.setWorkingDirectory(os.path.dirname(tmp_pth))
        process.setProcessChannelMode(QtCore.QProcess.MergedChannels)
        print('linter command: %s %s' % (pgm, ' '.join(args)))
        print('working directory: %s' % process.workingDirectory())
        process.start(pgm, args)
        process.waitForFinished()
        output = process.readAllStandardOutput().data().decode(
            locale.getpreferredencoding())
        print('linter raw output: %s' % output)
        messages = compiler.parse_output(output, tmp_name)
        print('linter parsed output: %r' % messages)
        os.remove(tmp_pth)
        return messages
    return []
Esempio n. 4
0
def lint(request_data):
    """
    Performs linting of a cobol document.

    This method will perform on the pyqode backend.

    :param request_data: work request data (dict)
    :return: status, messages
    """
    from open_cobol_ide.app import Application
    Application.init_env()
    code = request_data['code']
    path = request_data['path']
    extension = os.path.splitext(path)[1]
    if extension.lower() in settings.Settings().cobc_extensions:
        # code might not have been saved yet, run cobc on a tmp file
        # we use a time stamp to avoid overwriting the file another cobc
        # instance might be compiling.
        file_name = os.path.split(path)[1]
        file_name, ext = os.path.splitext(file_name)
        tmp_name = '%s.%s%s' % (file_name, str(int(time.time())), ext)
        tmp_pth = os.path.join(tempfile.gettempdir(), tmp_name)
        with open(tmp_pth, 'w') as f:
            f.write(code)
        compiler = GnuCobolCompiler()
        pgm, args = make_linter_command(tmp_name, path)
        process = QtCore.QProcess()
        process.setWorkingDirectory(os.path.dirname(tmp_pth))
        process.setProcessChannelMode(QtCore.QProcess.MergedChannels)
        print('linter command: %s %s' % (pgm, ' '.join(args)))
        print('working directory: %s' % process.workingDirectory())
        process.start(pgm, args)
        process.waitForFinished()
        output = process.readAllStandardOutput().data().decode(
            locale.getpreferredencoding())
        print('linter raw output: %s' % output)
        messages = compiler.parse_output(output, tmp_name)
        print('linter parsed output: %r' % messages)
        os.remove(tmp_pth)
        return messages
    return []