How to use the temci.utils.util.join_strs 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 _is_valid_csv_reporter_spec_list(specs: t.List[str]) -> bool:
    try:
        _parse_csv_reporter_specs(specs)
    except SyntaxError as err:
        return False
    return True

@register(ReporterRegistry, "csv", Dict({
    "out": FileNameOrStdOut() // Default("-") // Description("Output file name or standard out (-)"),
    "columns": ListOrTuple(Str()) // (lambda x: _is_valid_csv_reporter_spec_list(x))
               // Description("List of valid column specs, format is a comma separated list of 'PROPERTY\\[mod\\]' or 'ATTRIBUTE' "
                              "mod is one of: {}, optionally a formatting option can be given via"
                              "PROPERTY\\[mod|OPT1OPT2…\\], where the OPTs are one of the following: {}. "
                              "PROPERTY can be either the description or the short version of the property. "
                              "Configure the number formatting further via the number settings in the settings file"
                              .format(join_strs(valid_csv_reporter_modifiers),
                                      join_strs("{} ({})".format(k, v) for k, v in FORMAT_OPTIONS.items())))
    // Default(["description"])
}))
class CSVReporter(AbstractReporter):
    """
    Simple reporter that outputs just a configurable csv table with rows for each run block
    """

    def report(self) -> t.Optional[str]:
        """
        Create an report and output it as configured.

        :return: the report string if ``to_string == True``
        """
        if not self.misc["out"] == "-" and not os.path.exists(os.path.dirname(self.misc["out"])):
            logging.error("Folder for report ({}) doesn't exist".format(os.path.dirname(self.misc["out"])))
github parttimenerd / temci / temci / run / run_processor.py View on Github external
def store_and_teardown(self):
        """
        Teardown everything, store the result file, print a short report and send an email
        if configured to do so.
        """
        self.teardown()
        self.store()
        if len(self.stats_helper.valid_runs()) > 0 \
                and all(x.benchmarks() > 0 for x in self.stats_helper.valid_runs()):
            report = ""
            if not in_standalone_mode:
                report = ReporterRegistry.get_for_name("console", self.stats_helper)\
                         .report(with_tester_results=False, to_string=True)
            subject = "Finished " + join_strs([repr(run.description()) for run in self.stats_helper.valid_runs()])
            send_mail(Settings()["run/send_mail"], subject, report, [Settings()["run/out"]])
        if self.recorded_error():
            descrs = []
            msgs = []
            for (i, result) in self.erroneous_run_blocks:
                descr = self.run_blocks[i].description()
                descrs.append(descr)
                msg = descr + ":\n\t" + "\n\t".join(str(result.error).split("\n"))
                msgs.append(msg)
            subject = "Errors while benchmarking " + join_strs(descrs)
            send_mail(Settings()["run/send_mail"], subject, "\n\n".join(msgs), [Settings()["run/in"] + ".erroneous.yaml"])
github parttimenerd / temci / temci / package / action.py View on Github external
def _execute(self, db: Database):
        if self._unsupported_distribution():
            self._fail("Unsupported distribution {}, expected {}".format(get_distribution_name(),
                                                                        join_strs(self.possible_distributions, "or")))
github parttimenerd / temci / temci / utils / registry.py View on Github external
def format_str_list(val: t.List[str], sep: str = "and") -> str:
            return join_strs(list(map(repr, val)), sep)
github parttimenerd / temci / temci / report / report.py View on Github external
inner_html += """<div class="block">"""
            inner_html += self._extended_summary(single, with_title=True, title_level=2,
                                                 title_class="page-header") + """</div>"""
        for pair in self.stats.pairs:
            inner_html += """<div class="block">"""
            inner_html += self._extended_summary(pair, with_title=True, title_level=2,
                                                 title_class="page-header") + """</div>"""
        self._write(html.format(timespan=hf.format_timespan(time.time() - start_time), **locals()))
        logging.info("Finished generating html")
        logging.info("Generate images...")
        self._process_hist_cache(self._hist_async_img_cache.values(), "Generate images")
        self._process_boxplot_cache(self._boxplot_async_cache.values(), "Generate box plots")
        self._write(html.format(timespan=hf.format_timespan(time.time() - start_time), **locals()))
        if self.misc["gen_pdf"] or self.misc["gen_tex"]:
            strs = (["tex"] if self.misc["gen_tex"] else []) + (["pdf"] if self.misc["gen_pdf"] else [])
            self._process_hist_cache(self._hist_async_misc_cache.values(), "Generate {}".format(join_strs(strs)))
github parttimenerd / temci / temci / run / run_driver.py View on Github external
"""
        self.misc_settings = misc_settings
        """ Further settings """
        self.used_plugins = []  # type: t.List[RunDriverPlugin]
        """ Used and active plugins """
        miss_root_plugins = []
        is_root = has_root_privileges()
        for used in self.get_used_plugins():
            klass = self.get_class(used)
            if klass.needs_root_privileges and not is_root:
                miss_root_plugins.append(used)
            else:
                self.used_plugins.append(self.get_for_name(used))
        if miss_root_plugins:
            logging.warning("The following plugins are disabled because they need root privileges (consider using `--sudo`): " +
                            join_strs(miss_root_plugins))
        self.setup()
github parttimenerd / temci / temci / report / stats.py View on Github external
def generate_msg_text(self, show_parent: bool) -> str:
        """
        Generates the text of this message object.

        :param show_parent: Is the parent shown in after the properties? E.g. "blub of bla parent: …"
        :return: message text
        """
        val_strs = list(map(self._val_to_str, self.values))
        prop_strs = ["{} ({})".format(prop, val) for (prop, val) in zip(self.properties, val_strs)]
        props = util.join_strs(prop_strs)
        if show_parent:
            props += " of {}".format(self.parent.description())
        return self.message.format(b_val=self._val_to_str(self.border_value), props=props)
github parttimenerd / temci / temci / package / action.py View on Github external
def _execute(self, db: Database):
        if self._unsupported_distribution():
            expected = join_strs(["{} {} ".format(*l) for l in self.possible_distributions], "or")
            self._fail("Unsupported distribution {} and release {}, expected {}".format(get_distribution_name(),
                                                                                        get_distribution_release(),
                                                                                        expected))
github parttimenerd / temci / temci / misc / game.py View on Github external
<p class="lead">A comparison of {comparing_str}</p>
                  
                {inner_html}
                <footer class="footer">
                    Generated by <a href="https://github.com/parttimenerd/temci">temci</a>'s game.py in {timespan}<br>
                    The benchmarked algorithms and their inputs come from the
                    <a href="http://benchmarksgame.alioth.debian.org/">benchmarksgame</a>
                </footer>
             
          
        
    

        """
        lang = self.name
        comparing_str = util.join_strs(self.get_scores_per_impl().keys())
        html_func = html_func or self.get_html
        inner_html = html_func(base_dir + "/fig", 2, with_header=False)
        import humanfriendly
        timespan = humanfriendly.format_timespan(time.time() - START_TIME)
        srv = "" if USABLE_WITH_SERVER else "file:"
        return html.format(**locals())