def __init__(self, o, config):
        o = ConfigBase.merge(DEFAULTS, deepcopy(o))

        self.file = o.get('file', None)
        self.proc = int(o.get('proc', None))
        self.time_limit = float(o.get('time_limit', None))
        self.memory_limit = float(o.get('memory_limit', None))
        self.tags = set(o.get('tags', None))
        self.check_rules = o.get('check_rules', None)
        self.config = config

        if self.config:
            self.file = Paths.join(self.config.root, self.file)
            self.without_ext = Paths.basename(Paths.without_ext(self.file))
            self.shortname = '{name}.{proc}'.format(name=self.without_ext, proc=self.proc)

            self.fs = ConfigCaseFiles(
                root=self.config.root,
                ref_output=Paths.join(self.config.root, 'ref_output', self.without_ext),
                output=Paths.join(
                    self.config.root,
                    'test_results',
                    self.shortname
                ))
        else:
            # create temp folder where files will be
            tmp_folder = Paths.temp_file(o.get('tmp') + '-{date}-{time}-{rnd}')
            Paths.ensure_path(tmp_folder, is_file=False)

            self.fs = ConfigCaseFiles(
                root=tmp_folder,
                ref_output=tmp_folder,
                output=tmp_folder
            )
Ejemplo n.º 2
0
    def __init__(self, o, config):
        o = ConfigBase.merge(yamlc.DEFAULTS, deepcopy(o))

        self.file = o.get(yamlc.TAG_FILES, None)
        self.proc = int(o.get(yamlc.TAG_PROC, None))
        self.time_limit = float(o.get(yamlc.TAG_TIME_LIMIT, None))
        self.memory_limit = float(o.get(yamlc.TAG_MEMORY_LIMIT, None))
        self.tags = set(o.get(yamlc.TAG_TAGS, None))
        self.check_rules = o.get(yamlc.TAG_CHECK_RULES, None)
        self.config = config

        if self.config:
            self.file = Paths.join(self.config.root, Paths.basename(self.file))
            self.without_ext = Paths.basename(Paths.without_ext(self.file))
            self.shortname = '{name}.{proc}'.format(name=self.without_ext,
                                                    proc=self.proc)

            self.fs = yamlc.ConfigCaseFiles(
                root=self.config.root,
                ref_output=Paths.join(self.config.root, yamlc.REF_OUTPUT_DIR,
                                      self.without_ext),
                output=Paths.join(self.config.root, yamlc.TEST_RESULTS,
                                  self.shortname))
        else:
            # create temp folder where files will be
            tmp_folder = Paths.temp_file(o.get('tmp') + '-{date}-{time}-{rnd}')
            Paths.ensure_path(tmp_folder, is_file=False)

            self.fs = yamlc.ConfigCaseFiles(root=tmp_folder,
                                            ref_output=tmp_folder,
                                            output=tmp_folder)
    def open(self):
        if self.mode in {self.SHOW, self.HIDE}:
            return {self.SHOW: None, self.HIDE: subprocess.PIPE}.get(self.mode)

        if self.mode in {self.WRITE, self.APPEND, self.VARIABLE}:
            if not self.fp:
                Paths.ensure_path(self.filename)
                self.fp = open(self.filename, 'w+' if self.mode is self.WRITE else 'a+')
            return self.fp
Ejemplo n.º 4
0
    def copy(self):
        # create dirs for target file
        Paths.ensure_path(self.target)

        # copy file
        shutil.copy(self.source, self.target)

        # remove file if set
        if self.remove_original:
            os.unlink(self.source)
Ejemplo n.º 5
0
    def open(self):
        if self.mode in {self.SHOW, self.HIDE}:
            return {self.SHOW: None, self.HIDE: subprocess.PIPE}.get(self.mode)

        if self.mode in {self.WRITE, self.APPEND, self.VARIABLE}:

            # open file manually when append or write
            if self.mode in {self.WRITE, self.APPEND}:
                Paths.ensure_path(self.filename)
                self.fp = open(self.filename, 'w+' if self.mode is self.WRITE else 'a+')

            # create temp file otherwise
            if self.mode is self.VARIABLE:
                self.fp, self.filename = tempfile.mkstemp()
            return self.fp
Ejemplo n.º 6
0
    def open(self):
        if self.mode is self.DUMMY:
            return subprocess.PIPE

        if self.mode in {self.SHOW, self.HIDE}:
            return {self.SHOW: None, self.HIDE: subprocess.PIPE}.get(self.mode)

        if self.mode in {self.WRITE, self.APPEND, self.VARIABLE}:

            # open file manually when append or write
            if self.mode in {self.WRITE, self.APPEND}:
                Paths.ensure_path(self.filename)
                self.fp = open(self.filename,
                               'w+' if self.mode is self.WRITE else 'a+')

            # create temp file otherwise
            if self.mode is self.VARIABLE:
                self.fp, self.filename = tempfile.mkstemp()
            return self.fp
Ejemplo n.º 7
0
    def __init__(self, o, config):
        o = ConfigBase.merge(yamlc.DEFAULTS, deepcopy(o))

        self.file = o.get(yamlc.TAG_FILES, None)
        self.proc = int(o.get(yamlc.TAG_PROC, None))
        self.time_limit = float(o.get(yamlc.TAG_TIME_LIMIT, None))
        self.memory_limit = float(o.get(yamlc.TAG_MEMORY_LIMIT, None))
        self.tags = set(o.get(yamlc.TAG_TAGS, None))
        self.check_rules = o.get(yamlc.TAG_CHECK_RULES, None)
        self.config = config

        if self.config:
            self.file = Paths.join(self.config.root, Paths.basename(self.file))
            self.without_ext = Paths.basename(Paths.without_ext(self.file))
            self.shortname = '{name}.{proc}'.format(
                name=self.without_ext, proc=self.proc)

            self.fs = yamlc.ConfigCaseFiles(
                root=self.config.root,
                ref_output=Paths.join(
                    self.config.root, yamlc.REF_OUTPUT_DIR, self.without_ext),
                output=Paths.join(
                    self.config.root,
                    yamlc.TEST_RESULTS,
                    self.shortname
                ))
        else:
            # create temp folder where files will be
            tmp_folder = Paths.temp_file(o.get('tmp') + '-{date}-{time}-{rnd}')
            Paths.ensure_path(tmp_folder, is_file=False)

            self.fs = yamlc.ConfigCaseFiles(
                root=tmp_folder,
                ref_output=tmp_folder,
                output=tmp_folder
            )