pysavi is a thorough, documented and GPL'd python interface to the Sophos Anti-Virus Interface (SAVI).
pysavi offers the nuances and power of the C API while minimizing its inconvenience. You may, for example, scan mundane files, file descriptors, in-memory buffers or user implemented stream-like objects. Callbacks allow fine-grained inspection and control of the scanning process, including error reporting. Of course, any engine setting may be tweaked.
Python's standard SocketServer module makes the creation of robust, daemonized scanners quite easy. pysavi is threadsafe subject to the caveats of the underlying library.
docstrings are provided for every class and method. However, for first-time users, a copy of the Sophos "SAV Interface Developer Toolkit" user manual will be handy.
The current version is pysavi-0.31 (10 Mar 2005).
Requirements are Python >= 2.2, available at python.org, and libsavi, distributed by Sophos. Only Linux has been tested, but pysavi is expected to work on any UNIX/POSIX platform supporting Python and SAVI.
Previous versions, no longer recommended, were named 'pysavi2' to reflect the SAVI version in use at that time. The present module is a partial rewrite of those older attempts, exposing much more functionality (and SAVI itself experienced a few major version revs in the meantime).
The impatient, who just wish to scan a file and be done with it, should try something like this:
>>> import pysavi >>> sweeper = pysavi.Savi() # A/V engine handle >>> print s.GetVirusEngineVersion() # num. detectable viruses 92873 >>> opt_type = pysavi.SOPHOS_TYPE_OPTION_GROUP >>> for opt in ("GrpArchiveUnpack", "Mime"): ... sweeper.SetConfigValue(opt, opt_type, "1") ... >>> def scan_file(fn): ... viruses = sweeper.SweepFile(fn) ... return [ v.VirusName for v in viruses ] ... >>> scan_file("/tmp/clean.txt")  >>> scan_file('/tmp/eicar.com') ['EICAR-AV-Test']
Report problems, bugs, feature requests, successes to me at email@example.com.