def __init__(self, *args, **kwargs): self.repo = kwargs.pop("repo") forms.Form.__init__(self, *args, **kwargs) choices = [] repos = repo_utils.get_repos() if self.repo['parent']: choices.append((self.repo['parent']['id'], "Parent: %s" % self.repo['parent']['name'])) del repos[self.repo['parent']['id']] for child in self.repo['children']: choices.append((child['id'], "Child: %s" % child['name'])) del repos[child['id']] choices.extend(sorted([(r['id'], r['name']) for r in repos.values()], key=operator.itemgetter(1))) self.fields['repo2'].choices = choices
def list(request): taskapi = TaskAPI() tasktable = [] for task in CeleryTaskTracker.objects.filter(owner=request.user.username): tclass = getattr(tasks, task.taskclass) status = tclass.AsyncResult(task.taskid) stat_str = status.state if status.info: stat_str += ": %s" % status.info tasktable.append(dict(id=task.taskid, command=task.taskclass, status=stat_str, repo=None, type='sponge')) pulp_tasks = taskapi.list() if pulp_tasks: repos = repo_utils.get_repos() for task in taskapi.list(): if task['start_time'] is not None and task['state'] != 'finished': status = task['state'] command = task['method_name'].lstrip("_") if task['exception']: status += ": " + task['exception'] if task['scheduler'] == 'interval': ttype = task['scheduler'] command = "Scheduled %s" % command else: ttype = 'pulp' repo = None for arg in task['args']: if arg in repos: repo = arg break tasktable.append(dict(id=task['id'], command=command, status=status, repo=repo, started=parse_iso8601_datetime(task['start_time']), type=ttype)) return dict(tasks=tasktable)
def get_groups(): rv = set() for repo in repo_utils.get_repos().values(): rv.update(repo["groupid"]) return list(rv)
def list(request): """ list repos """ repos = repo_utils.get_repos().values() return dict(repositories=repo_utils.sort_repos_by_ancestry(repos))