Skip to main content

Asyncio python clamav client

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Pyvalve-0.1.2.tar.gz (16.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

Pyvalve-0.1.2-py3-none-any.whl (16.5 kB view details)

Uploaded Python 3

File details

Details for the file Pyvalve-0.1.2.tar.gz.

File metadata

  • Download URL: Pyvalve-0.1.2.tar.gz
  • Upload date:
  • Size: 16.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.6 CPython/3.8.10 Linux/5.18.10-76051810-generic

File hashes

Hashes for Pyvalve-0.1.2.tar.gz
Algorithm Hash digest
SHA256 9d39f893da1f4583497982474c68de4ace7837e45c4687142e7172f6ff24a920
MD5 9551fa627af91a303f1d27b8da2cf45f
BLAKE2b-256 308d2ae10db37bf2c336b002ff47eb04cc409a34a6bf219f31abf619ca5d97e3

See more details on using hashes here.

File details

Details for the file Pyvalve-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: Pyvalve-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 16.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.6 CPython/3.8.10 Linux/5.18.10-76051810-generic

File hashes

Hashes for Pyvalve-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 823f990a72b740e2957447d897d87e30ee9169982d9528444b08994846bbfff8
MD5 5cecbf1d5811068bec843ec856164f90
BLAKE2b-256 ffd72376a16e3ee83414bde63509074f24689def1c23c81b5b54f01e9bd450c1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page