How to use the aiofile.Writer function in aiofile

To help you get started, we’ve selected a few aiofile examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github molior-dbs / molior / molior / View on Github external
async def write_log(build_id, line):
    Writes given line to logfile for given

        build_id (int): The build's id.
        line (string): The log line.

    path = Path(Configuration().working_dir) / "buildout" / str(build_id) / "build.log"
    if not path.parent.exists():

    async with AIOFile(path, "a+") as afp:
        writer = Writer(afp)
        await writer(line)
github molior-dbs / molior / molior / api / View on Github external
async def ws_logs_connected(ws_client):
    token = ws_client.cirrina.request.match_info["token"]

    with Session() as session:
        build = session.query(Build).join(BuildTask).filter(BuildTask.task_id == token).first()
        if not build:
            logger.error("file_upload: no build found for token '%s'", token)
            # FIXME: disconnect
            return ws_client

    logger.debug("ws: recieving logs for build {}".format(
    filename = get_log_file_path(
    afp = AIOFile(filename, 'w')
    writer = Writer(afp)
    ws_client.cirrina.build_id =
    ws_client.cirrina.buildlog = (afp, writer)
    return ws_client