Ejemplo n.º 1
0
    def compare(self, reference_filepath, other_filepath, **kwargs):
        """
        Method can do anything as long as int value is returned
        :param reference_filepath:
        :param other_filepath:
        :param kwargs:
        :return:
        """

        reference_content = IO.read(
            Paths.abspath(reference_filepath)
        )
        other_content = IO.read(
            Paths.abspath(other_filepath)
        )

        self.output.write("In case of emergency,")
        self.output.write("    you can provide details on what went wrong")
        self.output.write("    using self.output.write method")
        self.output.write("")
        self.output.write("Error while comparing files \n{} \n{}"
                          .format(reference_filepath, other_filepath))

        # must return return-code!
        return 1
 def get_command(f1, f2, **details):
     return [
         Paths.ndiff(),
         '-r', str(details.get('r_tol', '100.01')),
         '-a', str(details.get('a_tol', '100.0001')),
         Paths.abspath(f1),
         Paths.abspath(f2)
     ]
Ejemplo n.º 3
0
 def get_command(f1, f2, **details):
     return [
         Paths.ndiff(),
         "-r",
         str(details.get("r_tol", "0.01")),
         "-a",
         str(details.get("a_tol", "0.0001")),
         Paths.abspath(f1),
         Paths.abspath(f2),
     ]
Ejemplo n.º 4
0
    def __iter__(self):
        fileset = formic.FileSet(self.includes, directory=self.source)
        for filename in fileset:

            name = Paths.basename(filename) if not self.name else self.name.format(
                path=self.create_path_dict(filename),
                name=Paths.basename(filename),
            )
            if self.flat:
                root = self.target
            else:
                rel_path = Paths.relpath(Paths.dirname(filename), Paths.abspath(self.source))
                root = Paths.abspath(Paths.join(self.target, rel_path))

            yield CopyRule(filename, Paths.join(root, name), self.remove_original)
Ejemplo n.º 5
0
    def on_complete(self, pypy=None):
        if self.pypy.returncode > 0:
            if self.message:
                Printer.separator()
                Printer.open()
                Printer.out(self.message)
            else:
                Printer.open()

            # if file pointer exist try to read errors and outputs
            output = self.pypy.executor.output.read()
            if output:
                if self.pypy.full_output:
                    Printer.out('Output (last {} lines, rest in {}): ', self.tail, Paths.abspath(self.pypy.full_output))
                else:
                    Printer.out('Output (last {} lines): ', self.tail)
                Printer.err(format_n_lines(output, -self.tail, indent=Printer.indent * '    '))
            Printer.close()
Ejemplo n.º 6
0
    def __init__(self, yaml_file):
        self.yaml_file = Paths.abspath(yaml_file)
        self.configuration = None

        # set default language as english
        os.environ['LC_ALL'] = 'C'
Ejemplo n.º 7
0
    def __init__(self, yaml_file):
        self.yaml_file = Paths.abspath(yaml_file)
        self.configuration = None

        # set default language as english
        os.environ["LC_ALL"] = "C"
Ejemplo n.º 8
0
    def compare(self, reference_filepath, other_filepath, **kwargs):
        """
        Method can do anything as long as int value is returned
        :param reference_filepath:
        :param other_filepath:
        :param kwargs:
        :return:
        """

        regex = kwargs.get('regex', None)
        substr = kwargs.get('substr', None)

        if regex is None and substr is None:
            self.output.write(
                "Invalid check rule! Specify either 'regex' or 'substr' keyword."
            )
            return 1

        # convert to str or compile to regex
        if substr is not None:
            substr = str(substr)
        if regex is not None:
            regex = re.compile(str(regex))

        # for regex comparison we ignore reference file
        # read job_output.log
        content = IO.read(Paths.abspath(other_filepath))

        # substr find
        if substr:
            found = False
            for line in content.splitlines():
                if line.find(substr) != -1:
                    found = True
                    self.output.write(
                        '[OK] Found substr "{substr}" in line:'.format(
                            **locals()))
                    self.output.write('    ' + line)
                    break
            if not found:
                self.output.write(
                    '[ERROR] Could not find substr "{substr}":'.format(
                        **locals()))
                return 1

        # regex match
        if regex:
            found = False
            for line in content.splitlines():
                if regex.findall(line):
                    found = True
                    self.output.write(
                        '[OK] Found regex "{regex.pattern}" in line:'.format(
                            **locals()))
                    self.output.write('    ' + line)
                    break
            if not found:
                self.output.write(
                    '[ERROR] Could not find regex {regex.pattern}:'.format(
                        **locals()))
                return 1

        # self.output.write("In case of emergency,")
        # self.output.write("    you can provide details on what went wrong")
        # self.output.write("    using self.output.write method")
        # self.output.write("")
        # self.output.write("Error while comparing files \n{} \n{}"
        #                   .format(reference_filepath, other_filepath))

        # must return return-code!
        return 0