Run as service
Tim Golden
tim.golden at viacom-outdoor.co.uk
Mon Jul 19 10:49:38 EDT 2004
[Larry Bates]
| You should probably get your hands on Mark Hammond's,
| excellent book, Python Programming on Win32. It
| has a very good section on writing services. I'm not
| sure you want this to run as a service.
|
| Also take a look at Sam Rushing's site. There is an
| example of a POP3 mailbox system-tray app. Should
| be a good example to work from. It may already to
| what you want.
["André Nobre" <andre at andrenobre.com.br>]
| > it gets some information from mails.txt* file and watch new mails. I
| > want to know how to leave this code running as service
| under windows and
| > send a warning message (like that windows popup messages)
| when a there
| > is a new e-mail.
While I second Larry's suggestion on getting the
Hammond/Robinson book, you don't need to have this
kind of thing running as a service unless you really
want it running when you're logged off. (Which I doubt
as having popup messages doesn't make lots of sense).
You can use Irmen de Jong's Kronos, coupled with the
pywin32 extensions (URLs below) to have something like
the following script in your Startup folder, run under
pythonw.exe. It will popup message boxes when you want,
but otherwise won't get in the way. If you really want
something in the systray then certainly look for examples
of that kind of code. But it's not strictly necessary.
Neither do you need Kronos: you could roll your own
time.sleep loop. But why bother, when someone's already
done the job?
<code>
import kronos
import win32ui
import win32con
def do_reminder ():
if win32ui.MessageBox ("Continue?", "Reminder", win32con.MB_YESNO) ==
win32con.IDNO:
raise KeyboardInterrupt
#
# Interrupt every 5 minutes
#
INTERVAL_SECS = 60 * 5
s = kronos.Scheduler ()
s.addIntervalTask (
action = do_reminder,
taskname = "Reminder",
initialdelay = 0,
interval = INTERVAL_SECS,
processmethod = s.PM_SEQUENTIAL,
actionargs = []
)
s.start ()
</code>
pywin32: http://pywin32.sf.net
Kronos: http://www.razorvine.net/download/kronos.py
TJG
________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________
More information about the Python-list
mailing list