Skip to main content

A Python wrapper around clamd, the ClamAV daemon

Project description

clamdpy

A Python wrapper around clamd, the ClamAV daemon.

This is a maintained and updated fork of https://github.com/graingert/python-clamd/, credit goes to the original developer(s).

Python versions PyPI version Code style: Black Ruff

Installation

Using pip:

pip install clamdpy

Usage

from io import BytesIO

from clamdpy import ClamdNetworkSocket

clamd = ClamdNetworkSocket(
    host="127.0.0.1",
    port=3310,
    timeout=15,
)

clamd.ping()
#> 'PONG'

clamd.version()
#> VersionInfo(version='ClamAV 0.103.9', signature=27065, signature_date=datetime(2023, 10, 18, 9, 49, 14))

# Raw response can be fetched as well:
clamd.version(raw=True)
#> 'ClamAV 0.103.9/27065/Wed Oct 18 09:49:14 2023'

clamd.instream(BytesIO(b"data"))
#> ScanResult(path='stream', reason=None, status='OK')

Most of the clamd commands are implemented (a couple ones are missing and should be implemented sooner or later).

It is possible to use UNIX sockets as well:

from clamdpy import ClamdUnixSocket

clamd = ClamdUnixSocket(path="/var/run/clamav/clamd.ctl")

Line delimitations

By default, \n will be used to terminate lines. Clamd also supports NULL characters:

from clamdpy import ClamdNetworkSocket

clamd = ClamdNetworkSocket(line_terminator="z")

[!WARNING]
Support for the NULL character isn't tested and may not work as it doesn't play well with Python. Use with caution.

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

clamdpy-0.1.0.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

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

clamdpy-0.1.0-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file clamdpy-0.1.0.tar.gz.

File metadata

  • Download URL: clamdpy-0.1.0.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.9

File hashes

Hashes for clamdpy-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d598124f5dfdcbe18bfb9bc75dbcef6a5f023fe1ff7b632a6126993f61c3bb13
MD5 8163ae88b71bb34a2e8a6a184a48345d
BLAKE2b-256 530a1214131c89b387d1bb31a4c743b7c161c554897b86b932efef10514602ac

See more details on using hashes here.

File details

Details for the file clamdpy-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: clamdpy-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.9

File hashes

Hashes for clamdpy-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5a5104b531905e1bf462bdaa09f118645fa2439cc14ba90ac8a1047e415cdc18
MD5 f679821964386d5db84082bb3562f717
BLAKE2b-256 aa0bb6d09b245a1f4fbe8eaaf33dcba58e4ac85c20742117582f2b5bcf3971d3

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