diff --git a/util/kojira b/util/kojira index 57b79693..ef53011c 100755 --- a/util/kojira +++ b/util/kojira @@ -494,19 +494,23 @@ class RepoManager(object): """ stats = self.tagUseStats(entry['taginfo']['id']) - # XXX - need to make sure our times aren't far off, otherwise this - # scoring could have the opposite of the desired effect - now = time.time() - #normalize use count - max_n = max([t.get('n_recent', 0) for t in self.needed_tags.values()]) + # normalize use count + max_n = max([t.get('n_recent', 0) for t in self.needed_tags.values()] + or [1]) + if max_n == 0: + # no recent use or missing data + max_n = 1 adj = stats['n_recent'] * 9.0 / max_n + 1 # 1.0 to 10.0 ts = entry['expire_ts'] age = time.time() - ts + # XXX - need to make sure our times aren't far off, otherwise this + # scoring could have the opposite of the desired effect if age < 0: self.logger.warning("Needed tag has future expire_ts: %r", entry) age = 0 entry['score'] = age * adj - self.logger.debug("Needed tag %s got score %.2f") + self.logger.debug("Needed tag %s got score %.2f", + entry['taginfo']['name'], entry['score']) # so a day old unused repo gets about the regen same score as a # 2.4-hour-old, very popular repo @@ -553,7 +557,7 @@ class RepoManager(object): self.session.multicall = True for task_id in task_ids: self.session.getTaskInfo(task_id) - for task_id, tinfo in zip(task_ids, self.session.multiCall(strict=True)): + for task_id, [tinfo] in zip(task_ids, self.session.multiCall(strict=True)): tstate = koji.TASK_STATES[tinfo['state']] tag_id = self.tasks[task_id]['tag_id'] if tstate == 'CLOSED': @@ -651,7 +655,7 @@ class RepoManager(object): # The largest hub impact is from the first part of the newRepo # task. Once it is waiting on subtasks, that part is over running_tasks += 1 - if task('maven'): + if task['maven']: running_tasks_maven += 1 if running_tasks >= self.options.max_repo_tasks: @@ -694,8 +698,9 @@ class RepoManager(object): time_expired = '???' else: time_expired = "%.1f" % (time.time() - expire_ts) - self.logger.info("Created newRepo task %s for tag %s (%s), expired" - "for %s sec", task_id, tag['id'], tag['name'], time_expired) + self.logger.info("Created newRepo task %s for tag %s (%s), " + "expired for %s sec", task_id, tag['taginfo']['id'], + tag['taginfo']['name'], time_expired) self.tasks[task_id] = { 'taskinfo': self.session.getTaskInfo(task_id), 'tag_id': tag['taginfo']['id'],