예제 #1
0
파일: ws.py 프로젝트: matthewrmshin/rose
 def _render(self, all_revs=0, data=None, filters=None, s=None):
     """Render return data with a template."""
     if data:
         for item in data:
             suite_id = SuiteId.from_idx_branch_revision(
                 item["idx"], item["branch"], item["revision"])
             item["href"] = suite_id.to_web()
             item["date"] = str(get_timepoint_from_seconds_since_unix_epoch(
                 item["date"]))
     tmpl = self.props["template_env"].get_template("prefix-index.html")
     self.write(tmpl.render(
         title=self.props["title"],
         host=self.props["host_name"],
         rose_version=self.props["rose_version"],
         script="/static",
         service_root=self.service_root,
         prefix=self.prefix,
         prefix_source_url=self.source_url,
         known_keys=self.dao.get_known_keys(),
         query_operators=self.dao.get_query_operators(),
         all_revs=all_revs,
         filters=filters,
         s=s,
         data=data)
     )
예제 #2
0
파일: ws.py 프로젝트: jmancell/rose
 def _render(self, all_revs=False, data=None, filters=None, s=None):
     if data:
         for item in data:
             suite_id = SuiteId.from_idx_branch_revision(
                 item["idx"], item["branch"], item["revision"])
             item["href"] = suite_id.to_web()
     template = self.template_env.get_template("prefix-index.html")
     return template.render(
                     web_prefix=cherrypy.request.script_name,
                     prefix=self.prefix,
                     prefix_source_url=self.source_url,
                     known_keys=self.dao.get_known_keys(),
                     query_operators=self.dao.get_query_operators(),
                     all_revs=all_revs,
                     filters=filters,
                     s=s,
                     data=data)
예제 #3
0
파일: ws.py 프로젝트: craigmaclachlan/rose
 def _render(self, all_revs=0, data=None, filters=None, s=None):
     """Render return data with a template."""
     if data:
         for item in data:
             suite_id = SuiteId.from_idx_branch_revision(
                 item["idx"], item["branch"], item["revision"])
             item["href"] = suite_id.to_web()
     template = self.template_env.get_template("prefix-index.html")
     return template.render(web_prefix=cherrypy.request.script_name,
                            prefix=self.prefix,
                            prefix_source_url=self.source_url,
                            known_keys=self.dao.get_known_keys(),
                            query_operators=self.dao.get_query_operators(),
                            all_revs=all_revs,
                            filters=filters,
                            s=s,
                            data=data)
예제 #4
0
파일: result.py 프로젝트: ScottWales/rose
 def _update_local_status_row(self, model, path, r_iter, data):
     """Update the status for a row of the treeview"""
     index_map, local_suites = data[0:2]
     idx = model.get_value(r_iter, index_map["idx"])
     branch = model.get_value(r_iter, index_map["branch"])
     revision = int(model.get_value(r_iter, index_map["revision"]))
     suite_id = SuiteId.from_idx_branch_revision(idx, branch, revision)
     status = suite_id.get_status()
     model.set_value(r_iter, index_map["local"], status)
     suite_id_text = suite_id.to_string_with_version()
     results = ""
     for line in self._result_info[idx, branch, revision].splitlines():
         if line == suite_id_text or ":" in line or not line:
             results += line + "\n"
         else:
             results += STATUS_TIP[status] + "\n"
     self._result_info[idx, branch, revision] = results
     return False
예제 #5
0
 def _update_local_status_row(self, model, path, r_iter, data):
     """Update the status for a row of the treeview"""
     index_map, local_suites = data[0:2]
     idx = model.get_value(r_iter, index_map["idx"])
     branch = model.get_value(r_iter, index_map["branch"])
     revision = int(model.get_value(r_iter, index_map["revision"]))
     suite_id = SuiteId.from_idx_branch_revision(idx, branch, revision)
     status = suite_id.get_status()
     model.set_value(r_iter, index_map["local"], status)
     suite_id_text = suite_id.to_string_with_version()
     results = ""
     for line in self._result_info[idx, branch, revision].splitlines():
         if line == suite_id_text or ":" in line or not line:
             results += line + "\n"
         else:
             results += STATUS_TIP[status] + "\n"
     self._result_info[idx, branch, revision] = results
     return False
예제 #6
0
 def _render(self, all_revs=0, data=None, filters=None, s=None):
     """Render return data with a template."""
     if data:
         for item in data:
             suite_id = SuiteId.from_idx_branch_revision(
                 item["idx"], item["branch"], item["revision"])
             item["href"] = suite_id.to_web()
             item["date"] = str(
                 get_timepoint_from_seconds_since_unix_epoch(item["date"]))
     tmpl = self.props["template_env"].get_template("prefix-index.html")
     return tmpl.render(title=self.props["title"],
                        host=self.props["host_name"],
                        rose_version=self.props["rose_version"],
                        script=cherrypy.request.script_name,
                        prefix=self.prefix,
                        prefix_source_url=self.source_url,
                        known_keys=self.dao.get_known_keys(),
                        query_operators=self.dao.get_query_operators(),
                        all_revs=all_revs,
                        filters=filters,
                        s=s,
                        data=data)
예제 #7
0
def _display_maps(opts, ws_client, dict_rows, url=None):
    """Display returned suite details."""
    report = ws_client.event_handler

    try:
        terminal_cols = int(ws_client.popen("stty", "size")[0].split()[1])
    except (IndexError, RosePopenError, ValueError):
        terminal_cols = None

    if terminal_cols == 0:
        terminal_cols = None

    if opts.quietness and not opts.print_format:
        opts.print_format = PRINT_FORMAT_QUIET
    elif not opts.print_format:
        opts.print_format = PRINT_FORMAT_DEFAULT

    all_keys = ws_client.get_known_keys()

    for dict_row in dict_rows:
        suite_id = SuiteId.from_idx_branch_revision(
            dict_row["idx"],
            dict_row["branch"],
            dict_row["revision"])
        dict_row["suite"] = suite_id.to_string_with_version()
        if "%local" in opts.print_format:
            dict_row["local"] = suite_id.get_status(
                getattr(opts, "user", None))
    all_keys += ["suite"]
    if "%local" in opts.print_format:
        all_keys += ["local"]

    more_keys = []
    for key in REC_COL_IN_FORMAT.findall(opts.print_format):
        if key not in all_keys:
            more_keys.append(key)
    all_keys += more_keys

    if opts.sort is None or opts.sort not in all_keys:
        opts.sort = "revision"
    dict_rows.sort(lambda x, y: cmp(x[opts.sort], y[opts.sort]))
    if opts.reverse:
        dict_rows.reverse()

    keylist = []
    for key in all_keys:
        if "%" + key in opts.print_format:
            keylist.append(key)

    if not opts.no_headers:
        dummy_row = {}
        for key in all_keys:
            dummy_row[key] = key
        dict_rows.insert(0, dummy_row)

    dict_rows = _align(dict_rows, keylist)

    for dict_row in dict_rows:
        out = opts.print_format
        for key, value in dict_row.items():
            if "%" + key in out:
                out = out.replace("%" + key, str(value), 1)
        out = out.replace("%%", "%").expandtabs().rstrip()

        report(SuiteEvent(out.expandtabs() + "\n"), prefix="",
               clip=terminal_cols)
        report(SuiteInfo(dict_row), prefix="")
    if url is not None:
        report(URLEvent(url + "\n"), prefix="")
예제 #8
0
def _display_maps(opts, ws_client, dict_rows, url=None):
    """Display returned suite details."""
    report = ws_client.event_handler

    try:
        terminal_cols = int(ws_client.popen("stty", "size")[0].split()[1])
    except (IndexError, RosePopenError, ValueError):
        terminal_cols = None

    if terminal_cols == 0:
        terminal_cols = None

    if opts.quietness and not opts.print_format:
        opts.print_format = PRINT_FORMAT_QUIET
    elif not opts.print_format:
        opts.print_format = PRINT_FORMAT_DEFAULT

    all_keys = ws_client.get_known_keys()

    for dict_row in dict_rows:
        suite_id = SuiteId.from_idx_branch_revision(dict_row["idx"],
                                                    dict_row["branch"],
                                                    dict_row["revision"])
        dict_row["suite"] = suite_id.to_string_with_version()
        if "%local" in opts.print_format:
            dict_row["local"] = suite_id.get_status(getattr(
                opts, "user", None))
    all_keys += ["suite"]
    if "%local" in opts.print_format:
        all_keys += ["local"]

    more_keys = []
    for key in REC_COL_IN_FORMAT.findall(opts.print_format):
        if key not in all_keys:
            more_keys.append(key)
    all_keys += more_keys

    if opts.sort is None or opts.sort not in all_keys:
        opts.sort = "revision"
    dict_rows.sort(lambda x, y: cmp(x[opts.sort], y[opts.sort]))
    if opts.reverse:
        dict_rows.reverse()

    keylist = []
    for key in all_keys:
        if "%" + key in opts.print_format:
            keylist.append(key)

    if not opts.no_headers:
        dummy_row = {}
        for key in all_keys:
            dummy_row[key] = key
        dict_rows.insert(0, dummy_row)

    dict_rows = _align(dict_rows, keylist)

    for dict_row in dict_rows:
        out = opts.print_format
        for key, value in dict_row.items():
            if "%" + key in out:
                out = unicode(out).replace(u"%" + unicode(key), unicode(value),
                                           1)
        out = unicode(out.replace("%%", "%").expandtabs().rstrip())

        report(SuiteEvent(out.expandtabs() + "\n"),
               prefix="",
               clip=terminal_cols)
        report(SuiteInfo(dict_row), prefix="")
    if url is not None:
        report(URLEvent(url + "\n"), prefix="")