[spambayes-dev] Windows implementation using Commandline(forSpamBayes)

Tony Meyer tameyer at ihug.co.nz
Tue Aug 10 08:21:10 CEST 2004


[This is rather old now - sorry; I missed that it hadn't been responded to
yet]

> (2) I discovered that the scripts would not run unless I copied the
> particular script from the script folder to the base folder. Was that
> correct? If so, should I have deleted the original file for 
> that script which I left in the scripts folder? (When I attempted
> to run the script from the scripts folder, I got an error message
> saying that stuff was not found.)

The typical thing to do here is to run "python setup.py install" in the root
spambayes directory.  This copies everything in spambayes/spambayes into
/Lib/site-packages/spambayes in your Python directory, and everything in
spambayes/scripts into /Scripts in your Python directory.  You can then run
the scripts from there (or anywhere else - the things that need to be found
are in the site-packages directory).

Alternatively, you can just set the environment variable PYTHONPATH to
include the path to the root spambayes directory.

> (6) At first sb_mboxtrain.py didn't work. It turns out, 
> various assumptions existed which didn't apply in my case.
> The closest function, as far as I could tell, was the
> "maildir_train" function for "maildir" -type mail boxes.
> But even this wasn't compatible. My mail was simply a 
> collection of text files in a folder.

I don't really know anything about sb_mboxtrain, so will have to skip this.
I would have thought that the text files could been treated as very small
mbox files, though.

> (7) This is where I am stuck. When I actually attempt to run 
> a file through the filter, I've used the following:
> 
> "sb_filter.py -f
> C:\SpamBayesServerEdition\inbox\20040624105403D1E2-00000002.tmp"
>
> It returns with NO feedback and NO errors.

sb_filter.py should print out (to the console) the resulting message.  For
example, run sb_filter.py with no arguments, type "Subject: Test", then
return then control-z and you should get a message printed out that includes
the classification header.  If it doesn't find any messages, then it does
nothing, so this is probably the case here.

It wants the filenames to be certain types of files, and a raw RFC822
message isn't one of them.  The easiest thing, if you are always going to
have a collection of text files (one per mesasge) would be to change

        mbox = mboxutils.getmbox(fname)
To
        mbox = [email.message_from_file(file(fname))]

In sb_filter.py, and put an "import email" up the top.

>     for fname in args:
>         print "fname: " % fname
> 
> (notice my print line I eventually added. When this print 
> line is place here, an error message occurs:

The problem here is that you don't have anywhere for the fname to go.  It
should be 'print "fname: %s" % fname' or just 'print "fname", fname'.

=Tony Meyer



More information about the spambayes-dev mailing list