Beispiel #1
0
 def append_patch_list(ticket, dependency=False):
     if ticket in seen_deps:
         return
     print "Looking at #%s" % ticket
     seen_deps.append(ticket)
     data = scrape(ticket)
     if dependency and 'closed' in data['status']:
         merged = data.get('merged')
         if merged is None:
             merged = data.get('milestone')
         if merged is None or compare_version(merged, base) <= 0:
             print "#%s already applied (%s <= %s)" % (ticket, merged, base)
             return
     if data['spkgs']:
         raise NotImplementedError, "Spkgs not yet handled."
     if data['depends_on']:
         for dep in data['depends_on']:
             if isinstance(dep, basestring) and '.' in dep:
                 if compare_version(base, dep) < 0:
                     raise ValueError, "%s < %s for %s" % (base, dep, ticket)
                 continue
             append_patch_list(dep, dependency=True)
     print "Patches for #%s:" % ticket
     print "    " + "\n    ".join(data['patches'])
     for patch in data['patches']:
         patchfile, hash = patch.split('#')
         desired_series.append((hash, patchfile, get_patch_url(ticket, patchfile)))
Beispiel #2
0
def rate_ticket(ticket, **conf):
    rating = 0
    if ticket['spkgs']:
        return # can't handle these yet
    elif not ticket['patches']:
        return # nothing to do
    for dep in ticket['depends_on']:
        if isinstance(dep, basestring) and '.' in dep:
            if compare_version(conf['base'], dep) < 0:
                # Depends on a newer version of Sage than we're running.
                return None
    for author in ticket['authors']:
        if author not in conf['trusted_authors']:
            return
        rating += conf['bonus'].get(author, 0)
    for participant in ticket['participants']:
        rating += conf['bonus'].get(participant, 0) # doubled for authors
    rating += len(ticket['participants'])
    # TODO: remove condition
    if 'component' in ticket:
        rating += conf['bonus'].get(ticket['component'], 0)
    rating += conf['bonus'].get(ticket['status'], 0)
    rating += conf['bonus'].get(ticket['priority'], 0)
    rating += conf['bonus'].get(str(ticket['id']), 0)
    redundancy = (100,)
    prune_pending(ticket)
    if not ticket.get('retry'):
        for reports in current_reports(ticket, base=conf['base']):
            redundancy = min(redundancy, compare_machines(reports['machine'], conf['machine'], conf['machine_match']))
    if not redundancy[-1]:
        return # already did this one
    return redundancy, rating, -int(ticket['id'])
Beispiel #3
0
 def rate_ticket(self, ticket):
     rating = 0
     if not ticket['spkgs'] and not ticket['patches']:
         return # nothing to do
     for dep in ticket['depends_on']:
         if isinstance(dep, basestring) and '.' in dep:
             if compare_version(self.base, dep) < 0:
                 # Depends on a newer version of Sage than we're running.
                 return None
     bonus = self.config['bonus']
     for author in ticket['authors'] or ticket['participants']:
         if author not in self.config['trusted_authors']:
             return
         rating += bonus.get(author, 0)
     for participant in ticket['participants']:
         rating += bonus.get(participant, 0) # doubled for authors
     rating += len(ticket['participants'])
     # TODO: remove condition
     if 'component' in ticket:
         rating += bonus.get(ticket['component'], 0)
     rating += bonus.get(ticket['status'], 0)
     rating += bonus.get(ticket['priority'], 0)
     rating += bonus.get(str(ticket['id']), 0)
     uniqueness = (100,)
     prune_pending(ticket)
     if not ticket.get('retry'):
         for report in self.current_reports(ticket, newer=True):
             uniqueness = min(uniqueness, compare_machines(report['machine'], self.config['machine'], self.config['machine_match']))
             if report['status'] != 'ApplyFailed':
                 rating += bonus.get("applies", 0)
             rating -= bonus.get("unique", 0)
     if not any(uniqueness):
         return # already did this one
     return uniqueness, rating, -int(ticket['id'])
Beispiel #4
0
 def create_connection(self):
     if self.proxy_host and self.proxy_port:
         _header = {}
         if self.proxy_username and self.proxy_password:
             _header['Proxy-Authorization'] = 'Basic %s' % (
                 util.base64_encode(str(self.proxy_username) + ':' + str(self.proxy_password)))
         if self.is_secure:
             if util.compare_version(sys.version.split()[0], '2.7.9') >= 0:
                 self.connection = httplib.HTTPSConnection(self.proxy_host,
                                                           port=self.proxy_port,
                                                           timeout=self.timeout,
                                                           context=self.myssl.SSLContext(
                                                               self.sslVersion))
             else:
                 self.connection = httplib.HTTPSConnection(self.proxy_host,
                                                           port=self.proxy_port,
                                                           timeout=self.timeout)
             self.connection.set_tunnel(self.host, port=443, headers=_header)
         else:
             self.connection = httplib.HTTPConnection(self.proxy_host,
                                                      port=self.proxy_port,
                                                      timeout=self.timeout)
             self.connection.set_tunnel(self.host, port=80, headers=_header)
         logging.debug('create connection to host: %s by proxy host: %s' % (
             self.host, self.proxy_host))
     else:
         if self.is_secure:
             self.connection = httplib.HTTPSConnection(self.host, port=443,
                                                       timeout=self.timeout,
                                                       context=self.myssl.SSLContext(
                                                           self.sslVersion)) if util.compare_version(
                 sys.version.split()[0],
                 '2.7.9') >= 0 else httplib.HTTPSConnection(self.host,
                                                            port=443,
                                                            timeout=self.timeout)
         else:
             self.connection = httplib.HTTPConnection(self.host, port=80,
                                                      timeout=self.timeout)
         logging.debug('create connection to host: ' + self.host)
Beispiel #5
0
 def preprocess_reports(all):
     for item in all:
         base_report = base_reports.get(item['base'] + "/" + "/".join(item['machine']), base_reports.get(item['base']))
         if base_report:
             item['base_log'] = urllib.quote(log_name(0, base_report))
         if 'patches' in item:
             required = info['depends_on'] + info['patches']
             item['patch_list'] = format_patches(ticket, item['patches'], item.get('deps'), required)
         if 'git_base' in item:
             git_log = item.get('git_log')
             item['git_log_len'] = '?' if git_log is None else len(git_log)
         item['raw_base'] = item['base']
         if compare_version(item['base'], base) < 0:
             item['base'] = "<span style='color: red'>%s</span>" % item['base']
         if 'time' in item:
             item['log'] = log_name(info['id'], item)
         yield item
Beispiel #6
0
 def preprocess_reports(all):
     for item in all:
         base_of_this_report = item['base']
         base_report = base_reports.get(item['base'] + "/" + "/".join(item['machine']), base_reports.get(item['base']))
         if base_report:
             item['base_log'] = quote(log_name(0, base_report))
         if 'git_base' in item:
             git_log = item.get('git_log')
             item['git_log_len'] = '?' if git_log is None else len(git_log)
         item['raw_base'] = item['base']
         if compare_version(item['base'], latest) < 0:
             item['base'] = "<span style='color: red'>%s</span>" % item['base']
         if 'time' in item:
             item['log'] = log_name(info['id'], item)
         if 'git_commit_human' not in item:
             item['git_commit_human'] = "%s new commits" % len(item['log'])
         for x in ('commit', 'base', 'merge'):
             field = 'git_%s_human' % x
             item[field] = format_git_describe(item.get(field, None))
         if chosen_base == 'all' or chosen_base == base_of_this_report:
             yield item
Beispiel #7
0
 def preprocess_reports(all):
     for item in all:
         base_report = base_reports.get(item['base'] + "/" + "/".join(item['machine']), base_reports.get(item['base']))
         if base_report:
             item['base_log'] = urllib.quote(log_name(0, base_report))
         if 'patches' in item:
             required = info['depends_on'] + info['patches']
             item['patch_list'] = format_patches(ticket, item['patches'], item.get('deps'), required)
         if 'git_base' in item:
             git_log = item.get('git_log')
             item['git_log_len'] = '?' if git_log is None else len(git_log)
         item['raw_base'] = item['base']
         if compare_version(item['base'], base) < 0:
             item['base'] = "<span style='color: red'>%s</span>" % item['base']
         if 'time' in item:
             item['log'] = log_name(info['id'], item)
         if 'git_commit_human' not in item:
             item['git_commit_human'] = "%s new commits" % len(item['log'])
         for x in ('commit', 'base', 'merge'):
             field = 'git_%s_human' % x
             item[field] = format_git_describe(item.get(field, None))
         yield item
Beispiel #8
0
def ticket_list():
    authors = None
    machine = None

    if 'base' in request.args:
        base = request.args.get('base')
        if base == 'all':
            base = None
        elif base == 'develop':
            base = 'latest'
    else:
        base = 'latest'

    query = get_query(request.args)
    if 'machine' in request.args:
        machine = request.args.get('machine').split(':')
    if 'authors' in request.args:
        authors = request.args.get('authors').split(':')
    if 'order' in request.args:
        order = request.args.get('order')
    else:
        order = 'last_activity'
    limit = int(request.args.get('limit', 1000))
    print(query)

    all = filter_on_authors(tickets.find(query).sort(order).limit(limit), authors)
    if 'raw' in request.args:
        # raw json file for communication with patchbot clients
        def filter_reports(all):
            for ticket in all:
                current = sorted(current_reports(ticket),
                                 key=lambda report: report['time'])
                ticket['reports'] = list(reversed(current))[:10]
                for report in ticket['reports']:
                    report['plugins'] = '...'
                yield ticket
        all = filter_reports(all)
        if 'pretty' in request.args:
            indent = 4
        else:
            indent = None
        response = make_response(json.dumps(list(all), default=lambda x: None,
                                            indent=indent))
        response.headers['Content-type'] = 'text/plain; charset=utf-8'
        return response

    summary = {key: 0 for key in status_order}

    def preprocess(all):
        for ticket in all:
            ticket['report_count'], ticket['report_status'], ticket['report_status_composite'] = get_ticket_status(ticket, machine=machine, base=base or 'latest')
            if 'reports' in ticket:
                ticket['pending'] = len([r for r in ticket['reports']
                                         if r['status'] == 'Pending'])
            summary[ticket['report_status']] += 1
            yield ticket

    ticket0 = tickets.find_one({'id': 0})
    base_status = get_ticket_status(ticket0, base)
    versions = list(set(report['base'] for report in ticket0['reports']))
    versions.sort(compare_version)
    versions = [v for v in versions if compare_version(v, OLDEST) == 1]
    versions = [(v, get_ticket_status(ticket0, v)) for v in versions]

    return render_template("ticket_list.html", tickets=preprocess(all),
                           summary=summary, base=base, base_status=base_status,
                           versions=versions, status_order=status_order,
                           compare_version=compare_version)