Skip to main content

pyvalve

Asyncio python clamav client library

Usage Examples

Ping

pvs = await PyvalveNetwork()
response = await pvs.ping()

ClamAv will respond with "PONG"

Scanning

pvs = await PyvalveNetwork()
response = await pvs.scan(path)

Stream Scanning

from io import BytesIO
from aiofile import AIOFile

buffer = BytesIO()
async with AIOFile('some/file', 'r') as file_pointer:
    line = await file_pointer.read_bytes()
    buffer.write(line)
    buffer.seek(0)
response = await pvs.instream(buffer)

Documentation

class Pyvalve()

Bases: object

Pyvalve base class

set_persistant_connection(persist)

Set persistent connection

  • Parameters

    bool (persist) – persistent connection True/False

  • Return type

    None

set_stream_buffer(length)

Set stream buffer

  • Parameters

    int (length) – Desired stream buffer in bytes

  • Return type

    None

async allmatchscan(path)

Send allmatchscan command

  • Parameters

    str (path) – Path to file/directory to be scanned

  • Returns

    Response from clamav

  • Return type

    str

  • Raises

    PyvalveScanningError – If path is not found

async contscan(path)

Send constscan command

  • Parameters

    str (path) – Path to file/directory to be scanned

  • Returns

    Response from clamav

  • Return type

    str

  • Raises

    PyvalveScanningError – If path is not found

async instream(buffer)

Send a stream to clamav

  • Parameters

    buffer (BinaryIO) – a buffer object

  • Returns

    Response from clamav

  • Return type

    str

  • Raises

    • PyvalveConnectionError – If connection is broken

    • PyvalveStreamMaxLength – If stream size limit exceeded

async multiscan(path)

Send multiscan command

  • Parameters

    str (path) – Path to file/directory to be scanned

  • Returns

    Response from clamav

  • Return type

    str

  • Raises

    PyvalveScanningError – If path is not found

async ping()

Send ping command

  • Returns

    Response from clamav

  • Return type

    str

async reload()

Send reload command

  • Returns

    Response from clamav

  • Return type

    str

async scan(path)

Send scan command

  • Parameters

    str (path) – Path to file/directory to be scanned

  • Returns

    Response from clamav

  • Return type

    str

  • Raises

    PyvalveScanningError – If path is not found

async shutdown()

Send shutdown command

  • Returns

    Response from clamav

  • Return type

    str

async stats()

Send stats command

  • Returns

    Response from clamav

  • Return type

    str

async version()

Send version command

  • Returns

    Response from clamav

  • Return type

    str

class PyvalveNetwork(host='localhost', port=3310, timeout=None)

Bases: Pyvalve

Asyncio Clamd network client

async _init_(host='localhost', port=3310, timeout=None)

PyvalveNetwork Constructor

  • Parameters

    • str (host) – host address for clamav

    • int (timeout) – listening port for clamav

    • int – socket timemout

class PyvalveSocket(socket='/tmp/clamd.socket', timeout=None)

Bases: Pyvalve

Asyncio Clamd socket client

async _init_(socket='/tmp/clamd.socket', timeout=None)

PyvalveSocket Constructor

  • Parameters

    • str (socket) – Path to socket file

    • int (timeout) – socket timemout

Exceptions

exception PyvalveError()

Bases: Exception

Pyvalve exception base class

exception PyvalveConnectionError()

Bases: PyvalveError

Exception communicating with clamd

exception PyvalveResponseError()

Bases: PyvalveError

Exception processing response

exception PyvalveScanningError()

Bases: PyvalveError

Exception scanning. Could be path not found.

exception PyvalveStreamMaxLength()

Bases: PyvalveResponseError

Exception using INSTREAM with a buffer length > StreamMaxLength in /etc/clamav/clamd.conf

Metadata

Release files for Pyvalve 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for Pyvalve 0.1.5
File Size Uploaded
pyvalve-0.1.5.tar.gz 10.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for Pyvalve 0.1.5
File Interpreter ABI Platform
pyvalve-0.1.5-py3-none-any.whl Python 3 none any Details

Total release size: 19.4 kB

Release files / pyvalve-0.1.5.tar.gz

Download URL pyvalve-0.1.5.tar.gz
Size 10.5 kB
Tags Source
SHA-256 checksum
How to use checksums
f0f0de7b188b836c7478d10e051209680ba89d38fcd6c46af04cc19f91d51265
BLAKE2b-256 checksum
How to use checksums
23e8dd218be89bb802c0cb8d16e6364ce47e0ee984a1f02554438c7f03971247
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / pyvalve-0.1.5-py3-none-any.whl

Download URL pyvalve-0.1.5-py3-none-any.whl
Size 8.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
223c1c7769470fb3d19d6c2cd8f8c2351da59579618ab7f8a0495a6062ffcab1
BLAKE2b-256 checksum
How to use checksums
768add3d87c80ae4490b6b376778df2c5e6909c561704dd21359996facc84281
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.1.5 This release

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page