About

pyClamd is a python interface to Clamd (Clamav daemon). By using pyClamd, you can add virus detection capabilities to your python software in an efficient and easy way.

Instead of pyClamav which uses libclamav, pyClamd may be used by a closed source product.

Download latest

pyClamd-0.3.4.tar.gz - 2013-11-17
md5sum is 1725c5f3a22d4fdb04de25a978787d5b
This version is compatible with python 3 (tested with 3.2.3) and python 2 (tested 2.7.3). The API for this new version is now object oriented. Usefull classes are ClamdNetworkSocket and ClamdUnixSocket. You can alway check documentation with :
pydoc pyclamd

Previous version

This version provides old API (functions) pyclamd_0.2.2.py - 2010-07-12
md5sum is f7b7a5bb2839bc3343735bc095f40aa9

Download development version

svn checkout http://pyclamd.googlecode.com/svn/trunk/ pyclamd-read-only top

Installation

These are generic installation instructions.

You need to have clamav with clamd installed. You also need to have python installed. Clamd should be accessible either by network or by unix socket.

You just have to copy pyclamd.py in your site-packages directory (for example : /usr/lib/python2.3/site-packages/). Or if you do not want a wide system installation, you can leave pyclamd.py in your application directory.

top

Usage

From python :
>>> import pyclamd
>>> try:
...     cd = pyclamd.ClamdUnixSocket()
...     # test if server is reachable
...     cd.ping()
... except pyclamd.ConnectionError:
...     # if failed, test for network socket
...     cd = pyclamd.ClamdNetworkSocket()
...     try:
...         cd.ping()
...     except pyclamd.ConnectionError:
...         raise ValueError('could not connect to clamd server either by unix or network socket')
True
>>> print(cd.version().split()[0])
ClamAV
>>> print(cd.reload())
RELOADING
>>> print(cd.stats().split()[0])
POOLS:
>>> void = open('/tmp/EICAR','w').write(cd.EICAR())
>>> void = open('/tmp/NO_EICAR','w').write('no virus in this file')
>>> cd.scan_file('/tmp/EICAR')
{'/tmp/EICAR': ('FOUND', 'Eicar-Test-Signature')}
>>> cd.scan_file('/tmp/NO_EICAR') is None
True
>>> cd.scan_stream(cd.EICAR())
{'stream': ('FOUND', 'Eicar-Test-Signature')}
top

Full documentation

Full documentation for pyclamd is available here. top

License

This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.