[Spambayes-checkins] spambayes/windows README.txt,NONE,1.1 pop3proxy_service.py,NONE,1.1

Mark Hammond mhammond at users.sourceforge.net
Wed Mar 12 05:22:46 EST 2003

Update of /cvsroot/spambayes/spambayes/windows
In directory sc8-pr-cvs1:/tmp/cvs-serv16014

Added Files:
	README.txt pop3proxy_service.py 
Log Message:
pop3proxy service for Windows 2000/XP.

--- NEW FILE: README.txt ---
This directory contains Windows specific functions for the spambayes project.

Currently this contains:
* Windows Service version of the pop3 proxy

Fairly short-term plans include:
* Inno setup installer for pop3proxy and Outlook.

--- NEW FILE: pop3proxy_service.py ---
# Run the pop3proxy as a WinNT service.  Should work on Windows 2000
# and Windows XP.
# * Install as a service using "pop3proxy_service.py install"
# * Start the service (Use Control Panel etc, or
#   "pop3proxy_service.py start".  Check the event
#   log should anything go wrong.
# * Service should display 
# * To debug the service: "pop3proxy_service.py debug"
#   Service then runs in the command prompt, showing all
#   print statements.
# * To remove the service: "pop3proxy_service.py remove"

# This module is part of the spambayes project, which is Copyright 2002
# The Python Software Foundation and is covered by the Python Software
# Foundation license.

# Originally written by Mark Hammond.

import sys, os
# We are in the 'spambayes\win32' directory.  We
# need the parent on sys.path, so 'spambayes.spambayes' is a package,
# and 'pop3proxy' is a module
sb_dir = os.path.dirname(os.path.dirname(__file__))

sys.path.insert(0, sb_dir)
# and change directory here, so pop3proxy uses the default
# config file etc

# Rest of the standard Python modules we use.
import traceback
import threading

# The spambayes imports we need.
import pop3proxy

# The win32 specific modules.
import win32serviceutil, win32service
import pywintypes, win32con, winerror

from ntsecuritycon import *

class Service(win32serviceutil.ServiceFramework):
    _svc_name_ = "pop3proxy"
    _svc_display_name_ = "SpamBayes pop3proxy Service"
    _svc_deps_ =  ['tcpip']
    def __init__(self, args):
        win32serviceutil.ServiceFramework.__init__(self, args)
        self.event_stop = threading.Event()
        self.thread = None

    def SvcStop(self):

    def SvcDoRun(self):
        # Setup our state etc
        assert not pop3proxy.state.launchUI, "Service can't launch a UI"

        # Start the thread running the server.
        thread = threading.Thread(target=self.ServerThread)

        # Write an event log record - in debug mode we will also 
        # see this message printed.
        import servicemanager
            (self._svc_name_, '')

        # Wait for the stop event.
        except KeyboardInterrupt:
        # How do we cleanly shutdown the server?
        # Write another event log record.
        s = pop3proxy.state
        status = " after %d sessions (%d ham, %d spam, %d unsure)" % \
                (s.totalSessions, s.numHams, s.numSpams, s.numUnsure)

            (self._svc_name_, status)

    def ServerThread(self):
        state = pop3proxy.state
        pop3proxy.main(state.servers, state.proxyPorts, state.uiPort, state.launchUI)

if __name__=='__main__':

More information about the Spambayes-checkins mailing list