next_tasks: New heuristics that takes srpm versions into account
This commit is contained in:
parent
f33cbd511e
commit
80bf0eaf21
@ -4,6 +4,7 @@ from __future__ import print_function
|
||||
from port_stats import colorize
|
||||
from port_stats import tasks
|
||||
from port_stats import lists
|
||||
from port_stats import rpm_ffi
|
||||
from port_stats import utils
|
||||
|
||||
|
||||
@ -43,16 +44,47 @@ def _task_colors(info, by_name):
|
||||
return frozenset(c for c in colors if c)
|
||||
|
||||
|
||||
def _srpm_nevr(srpm, by_name):
|
||||
if not srpm or not srpm.endswith('.src.rpm'):
|
||||
return None
|
||||
name, version, release = srpm[:-8].rsplit('-', 2)
|
||||
# XXX: assume epoch is the same as in new package
|
||||
try:
|
||||
epoch = by_name[name][2].epoch
|
||||
except KeyError:
|
||||
epoch = None
|
||||
return lists.NEVR(name, epoch, version, release)
|
||||
|
||||
|
||||
def _is_interesting_task(info, by_name,
|
||||
colors=frozenset(['ORANGE', 'YELLOW', 'EXTRA'])):
|
||||
if info['state'] == 'DONE' or not info['owner'].startswith('recycler'):
|
||||
return False
|
||||
for subtask in info['subtasks'].values():
|
||||
p = tasks.subtask_package(subtask)
|
||||
if colorize.package_color(p, by_name) not in colors:
|
||||
# not an outdated package -- not interesting
|
||||
continue
|
||||
srpm_nevr = _srpm_nevr(subtask.get('srpm'), by_name)
|
||||
if not srpm_nevr:
|
||||
# not a simple rebuild for this package -- interesting
|
||||
return True
|
||||
our_nevr = by_name[p][2]
|
||||
c = rpm_ffi.evr_cmp(our_nevr.evr, srpm_nevr.evr, 'pkg')
|
||||
if c < 0:
|
||||
# task package is newer -- interesting
|
||||
return True
|
||||
# no interesting subtasks
|
||||
return False
|
||||
|
||||
|
||||
def next_tasks(task_list, by_name, repo):
|
||||
def _colorize(p):
|
||||
return colorize.package_color(p, by_name) or 'NONE'
|
||||
|
||||
colors=frozenset(['ORANGE', 'YELLOW', 'EXTRA'])
|
||||
infos = sorted((t for t in task_list
|
||||
if t['state'] != 'DONE'
|
||||
and t['repo'] == repo
|
||||
and _task_colors(t, by_name) & colors
|
||||
and t['owner'].startswith('recycler')),
|
||||
if t['repo'] == repo
|
||||
and _is_interesting_task(t, by_name)),
|
||||
key=lambda x: utils.maybe_int(x['taskid']))
|
||||
|
||||
return [tasks.format_task(t, extra_info=_colorize) for t in infos]
|
||||
|
@ -59,12 +59,12 @@ def _epoch_to_pchar(epoch, mode):
|
||||
|
||||
def evr_cmp(evr1, evr2, mode):
|
||||
p_e1 = _epoch_to_pchar(evr1[0], mode)
|
||||
p_v1 = _FFI.new('char[]', evr1[1])
|
||||
p_r1 = _FFI.new('char[]', evr1[2])
|
||||
p_v1 = _FFI.new('char[]', str(evr1[1]))
|
||||
p_r1 = _FFI.new('char[]', str(evr1[2]))
|
||||
|
||||
p_e2 = _epoch_to_pchar(evr2[0], mode)
|
||||
p_v2 = _FFI.new('char[]', evr2[1])
|
||||
p_r2 = _FFI.new('char[]', evr2[2])
|
||||
p_v2 = _FFI.new('char[]', str(evr2[1]))
|
||||
p_r2 = _FFI.new('char[]', str(evr2[2]))
|
||||
|
||||
dep = _FFI.new('char[]', '')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user