Skip to main content

Wrapper for SpamAssassin SPAMC deamon

Project description

SpamAssassin Client python module

This is a python wrapper for SpamAssissin's SPAMC deamon. It provides these funtions:

  • get_score(float) - final score from spamassasin
  • get_fulltext(string) - full report as string from SpamAssasin deamon
  • get_report_json(json) - full report as JSON from SpamAssasin deamon

Instalation

Install SpamAssassin

sudo apt get spamassassin

Pytest needs to be installed to run tests

sudo apt install python-pytest

Use PIP package manager to install this module

pip install spamassassin_client

Example

Module can be used in following way:

import os

from spamassassin_client import SpamAssassin

FILES = [dict(type='spam', name='sample-spam.txt'),
	 dict(type='ham', name='sample-nonspam.txt')]

def main():

    path = os.path.dirname(__file__)
    for test in FILES:
	filename = os.path.join(path, test['name'])
	with open(filename,"rb") as f:            
	    print("\nProcessing file: {}".format(filename))
	    assassin = SpamAssassin(f.read())
	    print(assassin)
	    if assassin.is_spam():
	        print("The received message is considered spam with a score of {0}".format(assassin.get_score()))
	    print('\nreport_fulltext:', assassin.get_fulltext())
	    print('score:', assassin.get_score())
	    print('report_json:', assassin.get_report_json())

if __name__ == "__main__":
    main()

Run tests

pytest -v

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

spamassassin_client-0.0.2.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

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

spamassassin_client-0.0.2-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file spamassassin_client-0.0.2.tar.gz.

File metadata

  • Download URL: spamassassin_client-0.0.2.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/2.7.15rc1

File hashes

Hashes for spamassassin_client-0.0.2.tar.gz
Algorithm Hash digest
SHA256 2e7661fb0c4862c6083ca152d7dfaa13c9f9318d9f2ad05c572709b1484c8a98
MD5 57a25241efb7eb3a373f387e41d8801f
BLAKE2b-256 8976cc5af9bf8e8d770094472991bd58d98639fb0742d4657ce1a242980e224b

See more details on using hashes here.

File details

Details for the file spamassassin_client-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: spamassassin_client-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 3.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/2.7.15rc1

File hashes

Hashes for spamassassin_client-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4d1009e36820284187119596dbb9688e42a3a671ffa42477f0fb1e8a5323ab16
MD5 d8b776ca867ae990fd6a3084883ca194
BLAKE2b-256 2ae1738b028e06c7632da4490277a7622f2650d71958efcabd1ded8f9d495b39

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