Exemplo n.º 1
0
def parse_succeeded_packages():
    """
    Print a list of succeeded packages from the USER/COPR repository, one package per line
    If you are looking into this code because you think, that the script froze, be cool. It is just very slow, because
    it iterates 100 results from copr-fe per one result.
    """
    cl = create_client2_from_params(root_url=COPR_URL)
    copr = list(cl.projects.get_list(owner=USER, name=COPR, limit=1))[0]
    packages = {}

    limit = 100
    offset = 0
    while True:
        # @WORKAROUND This code is so ugly because we do not have support for Package resource in api_2 yet.
        # This is why we list all builds and examine their packages.
        builds = cl.builds.get_list(project_id=copr.id, limit=limit, offset=offset)
        if not list(builds):
            break

        for build in filter(lambda x: x.package_name and x.state == "succeeded", builds):
            packages[build.package_name] = build.state
        offset += limit

    for package in packages:
        print(package)
Exemplo n.º 2
0
def parse_succeeded_packages():
    """
    Print a list of succeeded packages from the USER/COPR repository, one package per line
    If you are looking into this code because you think, that the script froze, be cool. It is just very slow, because
    it iterates 100 results from copr-fe per one result.
    """
    cl = create_client2_from_params(root_url=COPR_URL)
    copr = filter(lambda copr: copr.owner == USER, cl.projects.get_list(name=COPR))[0]
    packages = {}

    limit = 100
    offset = 0
    while True:
        # @WORKAROUND This code is so ugly because we do not have support for Package resource in api_2 yet.
        # This is why we list all builds and examine their packages.
        builds = cl.builds.get_list(project_id=copr.id, limit=limit, offset=offset)
        if not list(builds):
            break

        for build in filter(lambda x: x.package_name and x.state == "succeeded", builds):
            packages[build.package_name] = build.state
        offset += limit

    for package in packages:
        print(package)
parser.add_argument(
    '--beurl',
    action='store',
    default='https://copr-be.cloud.fedoraproject.org',
    help=
    'use this url as baseurl to backend instead of\nhttps://copr-be.cloud.fedoraproject.org'
)
parser.add_argument('--user',
                    action='store',
                    help='only download gpg keys for projects of this user')
parser.add_argument('--project',
                    action='store',
                    help='only download gpg keys for projects of this name')
parser.add_argument('--isolate-files',
                    action='store_true',
                    help='Each GPG file is stored in separate file.')

args = parser.parse_args()

be_url_tmpl = args.beurl + '/results/{username}/{projectname}/pubkey.gpg'

cli = create_client2_from_params(root_url=args.feurl)
if args.file:
    output_file = open(args.file, 'w')
else:
    output_file = None
try:
    main()
except KeyboardInterrupt as e:
    pass
Exemplo n.º 4
0
def main():
    copr_url = "http://copr-fe-dev.cloud.fedoraproject.org"
    client = create_client2_from_params(
        root_url=copr_url,
        login="******",
        token="kxcnwfmleulpnkckzspxxgwhxjolhc"
    )

    def pp(project):
        print("Project: {} id {}, {}\n {}\n{}".format(
            project.name,
            project.id,
            project.description,
            project.repos,
            [(x, y.href) for x, y in project._links.items()]
        ))

    def t1():
        project = client.projects.get_one(2262)
        #
        pp(project)
        # import ipdb; ipdb.set_trace()
        x = 2

    # res = project.update()
    # print(res)
    #
    def t3(project):
        p = project.get_self()
        pp(p)

    def t2():
        plist = client.projects.get_list(limit=20)
        for p in plist:
            #print(p)
            #print(p.get_href_by_name("builds"))
            pp(p)
            print("==")
            print("==")
            print("==")


    #t1()
    # t2()

    def t4():
        project = client.projects.get_one(3554)
        #pp(project)
        #print(project._response.json)

        name = "fedora-21-x86_64"
        #pc = project.get_project_chroot(name)
        #print(pc)
        for pc in project.get_project_chroot_list():
            print(pc)

    t4()

    def t5():
        build = client.builds.get_one(117578)
        #build._handle.cancel(build._entity)
        build._handle.delete(build.id)
        #import ipdb; ipdb.set_trace()
        build = client.builds.get_one(117578)
        print(build)

    # t5()

    def t6():

        project = client.projects.get_one(3554)
        print(project)

        # new_c = project.get_project_chroot("epel-5-x86_64")
        # print(new_c)
        # new_c.disable()
        # time.sleep(3)

        for pc in project.get_project_chroot_list():
            print(pc)
            # pc.disable()



        x = 2

    t6()

    #
    def t7():

        srpm = "http://miroslav.suchy.cz/copr/copr-ping-1-1.fc20.src.rpm"

        b = client.builds.create_from_url(project_id=4007, srpm_url=srpm)
        """:type: Build"""
        print(b)
        b.cancel()
        b = b.get_self()
        print(b)
        #op = b.delete()
        #print(op)

    # t7()

    def t8():

        srpm = "/tmp/tito/copr-backend-1.73.tar.gz"
        b = client.builds.create_from_file(project_id=4007, file_path=srpm)
        print(b)
        b.cancel()
        b = b.get_self()
        print(b)

    # t8()

    def t9():

        mcl = client.mock_chroots.get_list(active_only=False)
        for mc in mcl:
            print(mc)

    # t9()

    def t10():
        pass
            gpg_out(args.isolate_files, project)
        _offset += _limit

parser = argparse.ArgumentParser(description='Download GPG keys for COPR projects.', formatter_class=RawTextHelpFormatter)
parser.add_argument('-f', '--file', action='store',
                    help='store keys to a file instead of printing to stdout')
parser.add_argument('--feurl', action='store', default='http://copr.fedorainfracloud.org/',
                    help='use this url as baseurl to frontend instead of\nhttp://copr.fedorainfracloud.org/')
parser.add_argument('--beurl', action='store', default='https://copr-be.cloud.fedoraproject.org',
                    help='use this url as baseurl to backend instead of\nhttps://copr-be.cloud.fedoraproject.org')
parser.add_argument('--user', action='store',
                    help='only download gpg keys for projects of this user')
parser.add_argument('--project', action='store',
                    help='only download gpg keys for projects of this name')
parser.add_argument('--isolate-files', action='store_true',
                    help='Each GPG file is stored in separate file.')

args = parser.parse_args()

be_url_tmpl = args.beurl+'/results/{username}/{projectname}/pubkey.gpg'

cli = create_client2_from_params(root_url=args.feurl)
if args.file:
    output_file = open(args.file, 'w')
else:
    output_file = None
try:
    main()
except KeyboardInterrupt as e:
    pass
Exemplo n.º 6
0
def main():
    copr_url = "http://copr-fe-dev.cloud.fedoraproject.org"
    client = create_client2_from_params(root_url=copr_url,
                                        login="******",
                                        token="kxcnwfmleulpnkckzspxxgwhxjolhc")

    def pp(project):
        print("Project: {} id {}, {}\n {}\n{}".format(
            project.name, project.id, project.description, project.repos,
            [(x, y.href) for x, y in project._links.items()]))

    def t1():
        project = client.projects.get_one(2262)
        #
        pp(project)
        # import ipdb; ipdb.set_trace()
        x = 2

    # res = project.update()
    # print(res)
    #
    def t3(project):
        p = project.get_self()
        pp(p)

    def t2():
        plist = client.projects.get_list(limit=20)
        for p in plist:
            #print(p)
            #print(p.get_href_by_name("builds"))
            pp(p)
            print("==")
            print("==")
            print("==")

    #t1()
    # t2()

    def t4():
        project = client.projects.get_one(3554)
        #pp(project)
        #print(project._response.json)

        name = "fedora-21-x86_64"
        #pc = project.get_project_chroot(name)
        #print(pc)
        for pc in project.get_project_chroot_list():
            print(pc)

    t4()

    def t5():
        build = client.builds.get_one(117578)
        #build._handle.cancel(build._entity)
        build._handle.delete(build.id)
        #import ipdb; ipdb.set_trace()
        build = client.builds.get_one(117578)
        print(build)

    # t5()

    def t6():

        project = client.projects.get_one(3554)
        print(project)

        # new_c = project.get_project_chroot("epel-5-x86_64")
        # print(new_c)
        # new_c.disable()
        # time.sleep(3)

        for pc in project.get_project_chroot_list():
            print(pc)
            # pc.disable()

        x = 2

    t6()

    #
    def t7():

        srpm = "http://miroslav.suchy.cz/copr/copr-ping-1-1.fc20.src.rpm"

        b = client.builds.create_from_url(project_id=4007, srpm_url=srpm)
        """:type: Build"""
        print(b)
        b.cancel()
        b = b.get_self()
        print(b)
        #op = b.delete()
        #print(op)

    # t7()

    def t8():

        srpm = "/tmp/tito/copr-backend-1.73.tar.gz"
        b = client.builds.create_from_file(project_id=4007, file_path=srpm)
        print(b)
        b.cancel()
        b = b.get_self()
        print(b)

    # t8()

    def t9():

        mcl = client.mock_chroots.get_list(active_only=False)
        for mc in mcl:
            print(mc)

    # t9()

    def t10():
        pass