def test_parse_valid_arches(self):
        r = koji.parse_arches('i386', to_list=True)
        self.assertEqual(['i386'], r)

        r = koji.parse_arches('i386 x86_64', to_list=True)
        self.assertEqual(['i386', 'x86_64'], r)

        r = koji.parse_arches('i386 x86_64   ', to_list=True)
        self.assertEqual(['i386', 'x86_64'], r)

        r = koji.parse_arches('i386,x86_64', to_list=True)
        self.assertEqual(['i386', 'x86_64'], r)
Exemplo n.º 2
0
def _list_tasks(options, session):
    "Retrieve a list of tasks"

    callopts = {
        'decode': True,
    }
    if not getattr(options, 'all', False):
        callopts['state'] = [koji.TASK_STATES[s] for s in ('FREE', 'OPEN', 'ASSIGNED')]

    if getattr(options, 'after', False):
        callopts['startedAfter'] = options.after
    if getattr(options, 'before', False):
        callopts['startedBefore'] = options.before

    if getattr(options, 'mine', False):
        if getattr(options, 'user', None):
            raise koji.GenericError("Can't specify 'mine' and 'user' in same time")
        user = session.getLoggedInUser()
        if not user:
            print("Unable to determine user")
            sys.exit(1)
        callopts['owner'] = user['id']
    if getattr(options, 'user', None):
        user = session.getUser(options.user)
        if not user:
            print("No such user: %s" % options.user)
            sys.exit(1)
        callopts['owner'] = user['id']
    if getattr(options, 'arch', None):
        callopts['arch'] = parse_arches(options.arch, to_list=True)
    if getattr(options, 'method', None):
        callopts['method'] = options.method
    if getattr(options, 'channel', None):
        chan = session.getChannel(options.channel)
        if not chan:
            print("No such channel: %s" % options.channel)
            sys.exit(1)
        callopts['channel_id'] = chan['id']
    if getattr(options, 'host', None):
        host = session.getHost(options.host)
        if not host:
            print("No such host: %s" % options.host)
            sys.exit(1)
        callopts['host_id'] = host['id']

    qopts = {'order': 'priority,create_time'}
    tasklist = session.listTasks(callopts, qopts)
    tasks = dict([(x['id'], x) for x in tasklist])

    # thread the tasks
    for t in tasklist:
        if t['parent'] is not None:
            parent = tasks.get(t['parent'])
            if parent:
                parent.setdefault('children', [])
                parent['children'].append(t)
                t['sub'] = True

    return tasklist
    def test_parse_invalid_arches(self):
        with self.assertRaises(koji.GenericError):
            koji.parse_arches(u'ěšč')

        with self.assertRaises(koji.GenericError):
            koji.parse_arches(u'i386;x86_64')

        with self.assertRaises(koji.GenericError):
            koji.parse_arches(u'i386,x86_64', strict=True)
Exemplo n.º 4
0
async def do(package: Package, build: Build, token: Optional[str]):
    try:
        if build.mbs:
            task_id = await mbs_client.build(token, package.name,
                                             build.import_commit.branch,
                                             build.import_commit.commit)

            build.mbs_id = task_id
            build.status = BuildStatus.BUILDING
            await build.save()
        else:
            default_target = tags.base()
            if package.repo == Repo.EXTRAS:
                default_target = tags.extras()

            target = default_target if not build.force_tag else build.force_tag

            host = f"git+https://{settings.gitlab_host}{settings.repo_prefix}"
            source = f"{host}/rpms/{gitlabify(package.name)}.git?#{build.import_commit.commit}"

            opts = {}
            if build.scratch:
                opts["scratch"] = True
            if build.arch_override:
                opts["arch_override"] = koji.parse_arches(build.arch_override)

            task_id = koji_session.build(source, target, opts)

            build.koji_id = task_id
            build.status = BuildStatus.BUILDING
            await build.save()
    except MBSConflictException:
        build.status = BuildStatus.CANCELLED
        await build.save()
    except Exception:
        raise