Exemplo n.º 1
0
async def _upload_artifact(existing_release, artifact):
    async_func = async_wrap(existing_release.upload_asset)

    with open(artifact["local_path"], "rb") as f:
        log.debug(f'Uploading artifact "{artifact["name"]}"...')
        await async_func(content_type=artifact["content_type"],
                         name=artifact["name"],
                         asset=f)
Exemplo n.º 2
0
async def test_async_wrap():
    # Based on https://dev.to/0xbf/turn-sync-function-to-async-python-tips-58nn
    async_sleep = utils.async_wrap(time.sleep)

    start_time = time.time()
    await asyncio.gather(async_sleep(0.1), async_sleep(0.1), async_sleep(0.1))
    elapsed_time = time.time() - start_time

    assert 0.0 <= elapsed_time <= 0.2
Exemplo n.º 3
0
async def _delete_artifact(existing_artifact):
    async_delete_release = async_wrap(existing_artifact.delete)
    await async_delete_release()
Exemplo n.º 4
0
async def _edit_existing_release(existing_release, release_config):
    async_edit_release = async_wrap(existing_release.edit)
    # XXX We don't include the `target_commitish` because we're likely dealing with a Github release which
    # likely built off git branches. See comment in _does_release_need_to_be_updated(), for more details.
    await async_edit_release(**_get_github_release_kwargs(release_config, include_target_commitish=False))
Exemplo n.º 5
0
async def _create_release(github_repository, release_config):
    async_create_release = async_wrap(github_repository.create_release)
    await async_create_release(**_get_github_release_kwargs(release_config))
Exemplo n.º 6
0
async def _get_release_from_tag(github_repository, git_tag):
    async_release_from_tag = async_wrap(github_repository.release_from_tag)
    return await async_release_from_tag(git_tag)
Exemplo n.º 7
0
async def _get_github_repository(github_client, release_config):
    async_get_github_repository = async_wrap(github_client.repository)
    return await async_get_github_repository(release_config["github_owner"], release_config["github_repo_name"])
Exemplo n.º 8
0
async def _init_github_client(token):
    async_github_constructor = async_wrap(GitHub)
    return await async_github_constructor(token=token)