Esempio n. 1
0
def translate_xsl(source, stylesheet):
    command_line = "xsltproc --output " + source + " " + stylesheet + " " + source

    LOGGER.info("Running %s", command_line)

    # TODO: TBC use append env or manage entire env for each COTS ?
    status = launch_command(command_line)

    # TODO: TBC MOve status to post ?
    # TODO: see status management by system command executor
    if status != 0:
        raise MajaIOError("Error running {}. Exit code {}".format(command_line, status))
Esempio n. 2
0
def uncompress_file(src, dst):
    command_line = "tar -xjf " + src + " -C " + dst

    LOGGER.info("Uncompress %s", command_line)

    # TODO: TBC use append env or manage entire env for each COTS ?
    status = launch_command(command_line)

    # TODO: TBC MOve status to post ?
    # TODO: see status management by system command executor
    if status != 0:
        raise MajaDataException("Error running {}. Exit code {}".format(command_line, status))
Esempio n. 3
0
    def run(self):
        """
        Run self.command_line
        """
        LOGGER.info("Running %s", self.command_line)

        # TODO: TBC use append env or manage entire env for each COTS ?
        self.status = launch_command(self.command_line)

        # TODO: TBC MOve status to post ?
        # TODO: see status management by system command executor
        if self.status != 0:
            raise MajaProcessingError("Error running {}. Exit code {}.".format(self.command_line, self.status))
Esempio n. 4
0
def check_xml(xml_file, schema_location=None, xsd_file=None):
    """
    #TODO: to be implemented
    :param xml_file:
    :param xsd_file:
    :return:
    """

    # -----------------------
    # Load the xml file
    dom_node = get_root_xml(xml_file, deannotate=True)

    if xsd_file is None:
        if schema_location is None:
            raise MajaDataException(
                "Either schema path or schema location needed to validate xml")
        # --------------------------------------
        # Get the schema location
        lXsdFilename = get_schema_location(dom_node)
        if lXsdFilename is None:
            raise MajaDataException(
                "Error while reading the attribute 'xsi:schemaLocation' or 'xsi:noNamespaceSchemaLocation' "
                + "in the xml file " + xml_file +
                ". Impossible to check the file with its schema!")

        LOGGER.debug("The Xsd Filename <" + lXsdFilename +
                     "> had been detected in the xml file <" + xml_file + ">.")

        # --------------------------------------
        # Get the full path of the schemalocation
        lFullXsdFilename = os.path.join(schema_location, lXsdFilename)
    else:
        lFullXsdFilename = xsd_file

    # --------------------------------------
    # Check the Xsd to the xml file
    result = launch_command("xmllint --noout " + xml_file + " --schema " +
                            lFullXsdFilename)
    if result != 0:
        raise MajaDataException("The xml file <" + xml_file +
                                "> is not conform with its schema <" +
                                lFullXsdFilename + "> ! ")
    # --------------------------------------
    LOGGER.debug("The XML file <" + xml_file + "> is conform with its schema.")

    return True