How to use the temci.utils.sudo_utils.chown function in temci

To help you get started, we’ve selected a few temci 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 parttimenerd / temci / temci / report / report.py View on Github external
def _write(self, html_string: str):
        """
        Store the html string in the appropriate file and append ""
        """
        report_filename = os.path.join(self.misc["out"], self.misc["html_filename"])
        with open(report_filename, "w") as f:
            f.write(html_string)
            logging.info("Wrote report into " + report_filename)
            chown(f)
github parttimenerd / temci / temci / report / report.py View on Github external
def xls(self) -> str:
        import tablib
        data = tablib.Dataset()
        data.headers = [cell.content for cell in [self.orig_anchor_cell] + self.header_row]
        for (hcell, row) in zip(self.header_col, self.content_cells):
            data.append([cell.content for cell in [hcell] + row])
        filename = self.parent.get_random_filename() + ".xls"
        with open(filename, "wb") as f:
            f.write(data.xls)
            chown(f)
        return filename
github parttimenerd / temci / temci / scripts / init.py View on Github external
fd = None # type: io.IOBase
    if os.path.exists(file):
        actions = {
            "append": "Append to the file",
            "overwrite": "Overwrite the file"
        }
        res = prompt("The file already exists. What should be done? ",
                  completer=WordCompleter(sorted(list(actions.keys())), meta_dict=actions, ignore_case=True),
                  validator=WordValidator(list(actions.keys()) + ["a", "o"], error_msg="Not a valid action"))
        if res.startswith("a"):
            fd = open(file, "a+")
        elif res.startswith("o"):
            fd = open(file, "w+")
    else:
        fd = open(file, "w+")
        chown(fd)

    blocks.append(prompt_dict_func())

    def store_in_file():
        #print(blocks)
        yaml.dump(blocks, fd)
        fd.flush()
        fd.close()

    while prompt_yesno("Add another {name}? ".format(name=name)):
        try:
            blocks.append(prompt_dict_func())
        except KeyboardInterrupt:
            store_in_file()
            return
        except BaseException as ex:
github parttimenerd / temci / temci / run / run_processor.py View on Github external
def store_erroneous(self):
        """ Store the failing program blocks in a file ending with ``.erroneous.yaml``. """
        if len(self.erroneous_run_blocks) == 0:
            return
        file_name = Settings()["run/in"] + ".erroneous.yaml"
        try:
            blocks = [self.runs[x[0]] for x in self.erroneous_run_blocks]
            with open(file_name, "w") as f:
                f.write(yaml.dump(blocks))
                chown(f)
        except IOError as err:
            logging.error("Can't write erroneous program blocks to " + file_name)
github parttimenerd / temci / temci / run / run_processor.py View on Github external
def store(self):
        """ Store the result file """
        try:
            self.stats_helper.add_property_descriptions(self.pool.run_driver.get_property_descriptions())
        except (IOError, OSError) as ex:
            logging.error(ex)
        if (len(self.stats_helper.valid_runs()) > 0 and all(x.benchmarks() > 0 for x in self.stats_helper.valid_runs())) \
            or Settings()["run/record_errors_in_file"]:
            with open(Settings()["run/out"], "w") as f:
                f.write(yaml.dump(self.stats_helper.serialize()))
                chown(f)