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.3.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.3-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: spamassassin_client-0.0.3.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.3.tar.gz
Algorithm Hash digest
SHA256 9c71e1a8ebab8bbdc75ecd09803973d21a57cccd3d61ce732d21bd5be4880788
MD5 2bde92fb2c3941b9af31810b12e1a732
BLAKE2b-256 59b9de5d92ce54acec8d6084950b5a291c3ff15f31a7bda1e20855c8100240d4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: spamassassin_client-0.0.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f8bc891e47326801f43224f0f6cd61640e383bbd8e3cd8d690e54f1a1f96ec0f
MD5 8f3f220873abf7b47f166a7e74d1e1fe
BLAKE2b-256 ad25949d8134e966b910bf2d7655474662d1bb2891bc62f26a92c590ad4f5a5d

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