pyzor.client¶
Networked spam-signature detection client.
>>> import pyzor
>>> import pyzor.client
>>> import pyzor.digest
>>> import pyzor.config
To load the accounts file:
>>> accounts = pyzor.config.load_accounts(filename)
To create a client (to then issue commands):
>>> client = pyzor.client.Client(accounts)
To create a client, using the anonymous user:
>>> client = pyzor.client.Client()
To get a digest (of an email.message.Message object, or similar):
>>> digest = pyzor.digest.get_digest(msg)
To query a server (where address is a (host, port) pair):
>>> client.ping(address)
>>> client.info(digest, address)
>>> client.report(digest, address)
>>> client.whitelist(digest, address)
>>> client.check(digest, address)
To query the default server (public.pyzor.org):
>>> client.ping()
>>> client.info(digest)
>>> client.report(digest)
>>> client.whitelist(digest)
>>> client.check(digest)
Response will contain, depending on the type of request, some of the following keys (e.g. client.ping()[‘Code’]):
All responses will have: - ‘Diag’ ‘OK’ or error message - ‘Code’ ‘200’ if OK - ‘PV’ Protocol Version - ‘Thread’
info and check responses will also contain: - ‘[WL-]Count’ Whitelist/Blacklist count
info responses will also have: - ‘[WL-]Entered’ timestamp when message was first whitelisted/blacklisted - ‘[WL-]Updated’ timestamp when message was last whitelisted/blacklisted
- class pyzor.client.BatchClient(accounts=None, timeout=None, spec=None, batch_size=10)¶
Bases: pyzor.client.Client
Like the normal Client but with support for batching reports.
- flush()¶
Deleting any saved digest reports.
- force()¶
Force send any remaining reports.
- report(digest, address=('public.pyzor.org', 24441))¶
- whitelist(digest, address=('public.pyzor.org', 24441))¶
- class pyzor.client.CheckClientRunner(routine, r_count=0, wl_count=0)¶
Bases: pyzor.client.ClientRunner
- handle_response(response, message)¶
- class pyzor.client.Client(accounts=None, timeout=None, spec=None)¶
Bases: object
- check(digest, address=('public.pyzor.org', 24441))¶
- info(digest, address=('public.pyzor.org', 24441))¶
- max_packet_size = 8192¶
- ping(address=('public.pyzor.org', 24441))¶
- pong(digest, address=('public.pyzor.org', 24441))¶
- read_response(sock, expected_id)¶
- report(digest, address=('public.pyzor.org', 24441))¶
- send(msg, address=('public.pyzor.org', 24441))¶
- timeout = 5¶
- whitelist(digest, address=('public.pyzor.org', 24441))¶
- class pyzor.client.ClientRunner(routine)¶
Bases: object
- handle_response(response, message)¶
mesaage is a string we’ve built up so far
- run(server, args, kwargs=None)¶
- class pyzor.client.InfoClientRunner(routine)¶
Bases: pyzor.client.ClientRunner
- handle_response(response, message)¶