How to use the pygccxml.utils.remove_file_no_raise function in pygccxml

To help you get started, we’ve selected a few pygccxml examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gccxml / pygccxml / pygccxml / parser / source_reader.py View on Github external
(msg, exit_status))
            else:
                if msg or exit_status or not \
                        os.path.isfile(xml_file):
                    if not os.path.isfile(xml_file):
                        raise RuntimeError(
                            "Error occurred while running " +
                            self.__config.xml_generator.upper() +
                            " xml file does not exist")
                    else:
                        raise RuntimeError(
                            "Error occurred while running " +
                            self.__config.xml_generator.upper() +
                            ": %s status:%s" % (msg, exit_status))
        except Exception:
            utils.remove_file_no_raise(xml_file, self.__config)
            raise
        finally:
            process.wait()
            process.stdout.close()
        return xml_file
github InsightSoftwareConsortium / ITK / pygccxml / parser / source_reader.py View on Github external
for "header" file. If destination_file_path is not None, then this file
        path will be used and returned.

        :param header: path to source file, that should be parsed
        :type header: str

        :param destination: if given, will be used as target file/path for
                            GCC-XML generated file.
        :type destination: str

        :rtype: path to GCC-XML generated file
        """
        gccxml_file = destination
        # If file specified, remove it to start else create new file name
        if gccxml_file:
            pygccxml.utils.remove_file_no_raise(gccxml_file)
        else:
            gccxml_file = pygccxml.utils.create_temp_file_name(suffix='.xml')
        try:
            ffname = header
            if not os.path.isabs(ffname):
                ffname = self.__file_full_name(header)
            command_line = self.__create_command_line(ffname, gccxml_file)

            process = subprocess.Popen(
                args=command_line,
                shell=True,
                stdin=subprocess.PIPE,
                stdout=subprocess.PIPE)
            process.stdin.close()

            gccxml_reports = []
github gccxml / pygccxml / pygccxml / parser / project_reader.py View on Github external
xml_file_path = reader.create_xml_file(
                        fc.data,
                        fc.cached_source_file)
                else:
                    xml_file_path = fc.cached_source_file
            else:
                xml_file_path = reader.create_xml_file_from_string(fc.data)
            with open(xml_file_path, "r") as xml_file:
                xml = xml_file.read()
            utils.remove_file_no_raise(xml_file_path, self.__config)
            self.__xml_generator_from_xml_file = \
                reader.xml_generator_from_xml_file
            return xml
        finally:
            if xml_file_path and delete_xml_file:
                utils.remove_file_no_raise(xml_file_path, self.__config)
github InsightSoftwareConsortium / ITK / pygccxml / parser / source_reader.py View on Github external
exit_status = process.returncode
            gccxml_msg = os.linesep.join([str(s) for s in gccxml_reports])
            if self.__config.ignore_gccxml_output:
                if not os.path.isfile(gccxml_file):
                    raise gccxml_runtime_error_t(
                        "Error occured while running GCC-XML: %s status:%s" %
                        (gccxml_msg, exit_status))
            else:
                if gccxml_msg or exit_status or not \
                        os.path.isfile(gccxml_file):
                    raise gccxml_runtime_error_t(
                        "Error occured while running GCC-XML: %s" %
                        gccxml_msg)
        except Exception as error:
            pygccxml.utils.remove_file_no_raise(gccxml_file)
            raise error
        return gccxml_file
github gccxml / pygccxml / pygccxml / parser / source_reader.py View on Github external
:param source_file: path to the source file that should be parsed.
        :type source_file: str

        :param destination: if given, will be used as target file path for
                            the xml generator.
        :type destination: str

        :rtype: path to xml file.

        """

        xml_file = destination
        # If file specified, remove it to start else create new file name
        if xml_file:
            utils.remove_file_no_raise(xml_file, self.__config)
        else:
            xml_file = utils.create_temp_file_name(suffix='.xml')

        ffname = source_file
        if not os.path.isabs(ffname):
            ffname = self.__file_full_name(source_file)
        command_line = self.__create_command_line(ffname, xml_file)

        process = subprocess.Popen(
            args=command_line,
            shell=True,
            stdout=subprocess.PIPE)

        try:
            results = []
            while process.poll() is None:
github cpc / tce / tce / Python-bindings / tools / pygccxml / pygccxml / parser / source_reader.py View on Github external
declarations, types = None, None
        gccxml_file = ''
        try:
            ffname = self.__file_full_name(source_file)
            self.logger.debug( "Reading source file: [%s]." % ffname )
            declarations = self.__dcache.cached_value( ffname, self.__config )
            if not declarations:
                self.logger.debug( "File has not been found in cache, parsing..." )
                gccxml_file = self.create_xml_file( ffname )
                declarations, files = self.__parse_gccxml_created_file( gccxml_file )
                self.__dcache.update( ffname, self.__config, declarations, files )
            else:
                self.logger.debug( "File has not been changed, reading declarations from cache." )
        except Exception, error:
            if gccxml_file:
                pygccxml.utils.remove_file_no_raise( gccxml_file )
            raise error
        if gccxml_file:
            pygccxml.utils.remove_file_no_raise( gccxml_file )
        return declarations
github cpc / tce / tce / Python-bindings / tools / pygccxml / pygccxml / parser / source_reader.py View on Github external
gccxml_reports = []
            while True:
                  data = output.readline()
                  gccxml_reports.append( data )
                  if not data:
                       break
            exit_status = output.close()
            gccxml_msg = ''.join(gccxml_reports)
            if self.__config.ignore_gccxml_output:
                if not os.path.isfile(gccxml_file):
                    raise gccxml_runtime_error_t( "Error occured while running GCC-XML: %s status:%s" % (gccxml_msg, exit_status) )
            else:
                if gccxml_msg or exit_status or not os.path.isfile(gccxml_file):
                    raise gccxml_runtime_error_t( "Error occured while running GCC-XML: %s" % gccxml_msg )
        except Exception, error:
            pygccxml.utils.remove_file_no_raise( gccxml_file )
            raise error
        return gccxml_file
github gccxml / pygccxml / pygccxml / parser / source_reader.py View on Github external
:param content: C++ source code
        :type content: str

        :param destination: file name for xml file
        :type destination: str

        :rtype: returns file name of xml file
        """
        header_file = utils.create_temp_file_name(suffix='.h')

        try:
            with open(header_file, "w+") as header:
                header.write(content)
            xml_file = self.create_xml_file(header_file, destination)
        finally:
            utils.remove_file_no_raise(header_file, self.__config)
        return xml_file
github gccxml / pygccxml / pygccxml / parser / source_reader.py View on Github external
self.logger.debug("Reading source file: [%s].", ffname)
            decls = self.__dcache.cached_value(ffname, self.__config)
            if not decls:
                self.logger.debug(
                    "File has not been found in cache, parsing...")
                xml_file = self.create_xml_file(ffname)
                decls, files = self.__parse_xml_file(xml_file)
                self.__dcache.update(
                    ffname, self.__config, decls, files)
            else:
                self.logger.debug((
                    "File has not been changed, reading declarations " +
                    "from cache."))
        except Exception:
            if xml_file:
                utils.remove_file_no_raise(xml_file, self.__config)
            raise
        if xml_file:
            utils.remove_file_no_raise(xml_file, self.__config)

        return decls