I had to do this just yesterday, and the urllib.py module made it absolutely painless. Here's the simplistic little script I came up with, which could be called by cron, or some other task manager. This ia probably way less cool than the answer you're looking for, but it might give someone else some ideas . . . Later, Jerry S. --------------------------------------------------- """ urlgrabr.py is a simple script to hit an URL, capture the generated output, and manipulate it, based on parameters. e.g. save it as a file, python urlgrabr.py http://server/folder/object file=filename.html Default is simply to request the URL, and exit, dumping all data. """ import urllib import sys import string c_url = sys.argv[1] c_action = None u_url = urllib.urlopen(c_url) if len(sys.argv) > 2 : c_action = sys.argv[2] if string.lower(c_action[:5]) == "file=" : f_action = open(c_action[5:], "w") # file name for l in u_url.readlines() : if string.strip(l[:-1]) : f_action.write(l) f_action.close()
Thanks Jerry. Yes, just getting cron to run a Zope method is easy. I'm thinking in terms of a Zope ISP. Individual users generally do not have the privilege or telnet access to create crontabs and the ISP's support department doesn't want to have to do it for the users. So I (a user not an ISP) am interested in creating a means so that the ISP would only have to set up one crontab for each customer and would never have to change it (except maybe for the frequency, and perhaps there's a way to parameterize that). The crontab would run a Zope Dispatcher which would then dispatch Zope methods that had been scheduled from within Zope. Thus, Zope would acquire cronish capabilities. Because I'm also thinking about repetitive tasks, I'm not anxious to have to capture the outputs of the scheduled methods. I'd have to add them to the end of a log file, and have to worry about what happens when more than one copy of the method is running. I thought I'd expect scheduled methods to have side-effects, but no STDOUT output, and throw away any output that might be created. Do you think it's important to capture output? The kinds of scheduled tasks I'm thinking about are - email reminders - garbage collection - updating syndicated content from other sites Anybody have other examples with other use patterns? -- Loren
-----Original Message----- From: zope-dev-admin@zope.org [mailto:zope-dev-admin@zope.org]On Behalf Of Jerry.Spicklemire@IFLYATA.COM Sent: Friday, February 04, 2000 11:28 To: zope-dev@zope.org Subject: [Zope-dev] Re. Scheduler product, anyone?
I had to do this just yesterday, and the urllib.py module made it absolutely painless. Here's the simplistic little script I came up with, which could be called by cron, or some other task manager. This ia probably way less cool than the answer you're looking for, but it might give someone else some ideas . . .
Later, Jerry S. ---------------------------------------------------
""" urlgrabr.py is a simple script to hit an URL, capture the generated output, and manipulate it, based on parameters.
e.g. save it as a file,
python urlgrabr.py http://server/folder/object file=filename.html
Default is simply to request the URL, and exit, dumping all data. """
import urllib import sys import string
c_url = sys.argv[1]
c_action = None
u_url = urllib.urlopen(c_url)
if len(sys.argv) > 2 :
c_action = sys.argv[2]
if string.lower(c_action[:5]) == "file=" :
f_action = open(c_action[5:], "w") # file name for l in u_url.readlines() : if string.strip(l[:-1]) : f_action.write(l) f_action.close()
_______________________________________________ Zope-Dev maillist - Zope-Dev@zope.org http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
On Fri, 4 Feb 2000, Loren Stafford wrote:
The kinds of scheduled tasks I'm thinking about are - email reminders - garbage collection - updating syndicated content from other sites
Anybody have other examples with other use patterns?
Performing tasks in the background (eg. sending multiple emails, paging technical support). Just schedule with a time of 'now'. A more intelligent queue based email system, that can retry later if your SMTP host is down. Packing your ZODB regularly. Rebuilding/reindexing Catalog's Removing old Sessions (from SQLSession or FSSession). -- ___ // Zen (alias Stuart Bishop) Work: zen@cs.rmit.edu.au // E N Senior Systems Alchemist Play: zen@shangri-la.dropbear.id.au //__ Computer Science, RMIT WWW: http://www.cs.rmit.edu.au/~zen
participants (3)
-
Jerry.Spicklemire@IFLYATA.COM -
Loren Stafford -
Stuart 'Zen' Bishop