Created
March 22, 2019 20:01
-
-
Save eclipseo/8d68f112a5a0d89cf95c8f217f8a8c6f to your computer and use it in GitHub Desktop.
Add new rust packages to Anitya and assign Rust SIG commit rights
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
import aiohttp | |
import sys | |
import os | |
def get_subdirectories(dir): | |
return [name for name in os.listdir(dir) | |
if os.path.isdir(os.path.join(dir, name))] | |
async def main(paths): | |
pkgs = [pkg[5:] for pkg in paths if pkg.startswith('rust-')] | |
for pkg in pkgs: | |
print(pkg) | |
async with aiohttp.ClientSession() as session: | |
url = f'https://release-monitoring.org/api/project/fedora/rust-{pkg}' | |
async with session.get(url) as resp: | |
jsonresp = await resp.json() | |
if 'error' in jsonresp: | |
print(jsonresp['error']) | |
url = f'https://release-monitoring.org/api/v2/projects/' | |
pdata = {'backend': 'crates.io', | |
'homepage': f'https://crates.io/crates/{pkg}', | |
'name': pkg, | |
'check_release': True} | |
async with session.post(url, json=pdata, headers={'Authorization': 'token FIXME'}) as resp: | |
print(await resp.json()) | |
#resp.raise_for_status() | |
url = f'https://release-monitoring.org/api/v2/packages/' | |
pdata = {'distribution': 'Fedora', | |
'package_name': f'rust-{pkg}', | |
'project_name': pkg, | |
'project_ecosystem': 'crates.io'} | |
async with session.post(url, json=pdata, headers={'Authorization': 'token FIXME'}) as resp: | |
print(await resp.json()) | |
#resp.raise_for_status() | |
else: | |
print(f'rust-{pkg} is already set up.') | |
async with aiohttp.ClientSession() as session: | |
url = f'https://src.fedoraproject.org/api/0/rpms/rust-{pkg}/git/modifyacls' | |
pdata = {'user_type': 'group', | |
'name': 'rust-sig', | |
'acl': 'commit'} | |
async with session.post(url, json=pdata, headers={'Authorization': 'token FIXME'}) as resp: | |
print(await resp.json()) | |
#resp.raise_for_status() | |
if __name__ == '__main__': | |
if len(sys.argv) > 1 and os.path.isdir(sys.argv[1]): | |
asyncio.run(main(get_subdirectories(sys.argv[1]))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment