def waiting(): """ Return list of waiting actions and builds. """ # models.Actions actions_list = [ action.to_dict(options={ "__columns_except__": ["result", "message", "ended_on"] }) for action in actions_logic.ActionsLogic.get_waiting() ] # tasks represented by models.BuildChroot with some other stuff builds_list = [] for task in BuildsLogic.get_build_task_queue().limit(200): try: copr = task.build.copr # we are using fake username's here if copr.is_a_group_project: user_name = u"@{}".format(copr.group.name) else: user_name = copr.user.name record = { "task_id": task.task_id, "build_id": task.build.id, "project_owner": user_name, "project_name": task.build.copr.name, "submitter": task.build.user.name if task.build.user else None, # there is no user for webhook builds "pkgs": task.build.pkgs, # TODO to be removed "chroot": task.mock_chroot.name, "repos": task.build.repos, "memory_reqs": task.build.memory_reqs, "timeout": task.build.timeout, "enable_net": task.build.enable_net, "git_repo": task.build.package.dist_git_repo, "git_hash": task.git_hash, "git_branch": helpers.chroot_to_branch(task.mock_chroot.name), "package_name": task.build.package.name, "package_version": task.build.pkg_version } copr_chroot = CoprChrootsLogic.get_by_name_safe(task.build.copr, task.mock_chroot.name) if copr_chroot: record["buildroot_pkgs"] = copr_chroot.buildroot_pkgs else: record["buildroot_pkgs"] = "" builds_list.append(record) except Exception as err: app.logger.exception(err) response_dict = {"actions": actions_list, "builds": builds_list} return flask.jsonify(response_dict)
def waiting(): """ Return list of waiting actions and builds. """ # models.Actions actions_list = [ action.to_dict( options={"__columns_except__": ["result", "message", "ended_on"]}) for action in actions_logic.ActionsLogic.get_waiting() ] # tasks represented by models.BuildChroot with some other stuff builds_list = [] for task in BuildsLogic.get_build_task_queue().limit(200): try: copr = task.build.copr # we are using fake username's here if copr.is_a_group_project: user_name = u"@{}".format(copr.group.name) else: user_name = copr.owner.name record = { "task_id": "{}-{}".format(task.build.id, task.mock_chroot.name), "build_id": task.build.id, "project_owner": user_name, "project_name": task.build.copr.name, "submitter": task.build.user.name, "pkgs": task.build.pkgs, # TODO to be removed "chroot": task.mock_chroot.name, "repos": task.build.repos, "memory_reqs": task.build.memory_reqs, "timeout": task.build.timeout, "enable_net": task.build.enable_net, "git_repo": task.build.package.dist_git_repo, "git_hash": task.git_hash, "git_branch": helpers.chroot_to_branch(task.mock_chroot.name), "package_name": task.build.package.name, "package_version": task.build.pkg_version } copr_chroot = CoprChrootsLogic.get_by_name_safe( task.build.copr, task.mock_chroot.name) if copr_chroot: record["buildroot_pkgs"] = copr_chroot.buildroot_pkgs else: record["buildroot_pkgs"] = "" builds_list.append(record) except Exception as err: app.logger.exception(err) response_dict = {"actions": actions_list, "builds": builds_list} return flask.jsonify(response_dict)
def build_config(build_chroot): config = generate_build_config(build_chroot.build.copr, build_chroot.name) copr_chroot = CoprChrootsLogic.get_by_name_safe(build_chroot.build.copr, build_chroot.name) return { "repos": config.get("repos"), "additional_repos": generate_additional_repos(copr_chroot), "additional_packages": config.get("additional_packages"), "use_bootstrap_container": config.get("use_bootstrap_container"), "with_opts": config.get("with_opts"), "without_opts": config.get("without_opts"), "memory_limit": build_chroot.build.memory_reqs, "timeout": build_chroot.build.timeout, "enable_net": build_chroot.build.enable_net, "is_background": build_chroot.build.is_background, }
def waiting(): """ Return a single action and a single build. """ action_record = None build_record = None action = actions_logic.ActionsLogic.get_waiting().first() if action: action_record = action.to_dict(options={ "__columns_except__": ["result", "message", "ended_on"] }) task = BuildsLogic.get_build_task() if task: try: build_record = { "task_id": task.task_id, "build_id": task.build.id, "project_owner": task.build.copr.owner_name, "project_name": task.build.copr.name, "submitter": task.build.user.name if task.build.user else None, # there is no user for webhook builds "pkgs": task.build.pkgs, # TODO to be removed "chroot": task.mock_chroot.name, "repos": task.build.repos, "memory_reqs": task.build.memory_reqs, "timeout": task.build.timeout, "enable_net": task.build.enable_net, "git_repo": task.build.package.dist_git_repo, "git_hash": task.git_hash, "git_branch": helpers.chroot_to_branch(task.mock_chroot.name), "package_name": task.build.package.name, "package_version": task.build.pkg_version } copr_chroot = CoprChrootsLogic.get_by_name_safe(task.build.copr, task.mock_chroot.name) if copr_chroot: build_record["buildroot_pkgs"] = copr_chroot.buildroot_pkgs else: build_record["buildroot_pkgs"] = "" except Exception as err: app.logger.exception(err) response_dict = {"action": action_record, "build": build_record} return flask.jsonify(response_dict)