File: sb_client.py

package info (click to toggle)
spambayes 1.1a6-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 4,712 kB
  • sloc: python: 48,776; ansic: 535; sh: 87; lisp: 83; makefile: 46
file content (29 lines) | stat: -rw-r--r-- 593 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#! /usr/bin/env python

"""A client for sb_xmlrpcserver.py.

Just feed it your mail on stdin, and it spits out the same message
with the spambayes score in a new X-Spambayes-Disposition header.

"""

import xmlrpclib
import sys

RPCBASE = "http://localhost:65000"

def main():
    msg = sys.stdin.read()
    try:
        x = xmlrpclib.ServerProxy(RPCBASE)
        m = xmlrpclib.Binary(msg)
        out = x.filter(m)
        print out.data
    except:
        if __debug__:
            import traceback
            traceback.print_exc()
        print msg

if __name__ == "__main__":
    main()