------------------------------------------------------------
revno: 6560
committer: Barry Warsaw <[EMAIL PROTECTED]>
branch nick: 3.0
timestamp: Sat 2007-09-29 11:09:14 -0400
message:
qrunner, mailmanctl and various other repairs.
The convenience methods in Defaults for getting seconds, minutes, hours, and
days now returns a subtype of timedelta, which provides conversion to float
and int for compatibility with interfaces that require those values
(e.g. signal.alarm() and time.sleep().
In bin/make_instance, the var_dir really needs to be an absolute path,
otherwise it's possible to get a var dir nested inside the var dir.
More MailList object eradication.
modified:
Mailman/Defaults.py
Mailman/LockFile.py
Mailman/Queue/BounceRunner.py
Mailman/Queue/RetryRunner.py
Mailman/Queue/Runner.py
Mailman/bin/mailmanctl.py
Mailman/bin/make_instance.py
Mailman/bin/withlist.py
=== modified file 'Mailman/Defaults.py'
--- a/Mailman/Defaults.py 2007-09-28 02:15:00 +0000
+++ b/Mailman/Defaults.py 2007-09-29 15:09:14 +0000
@@ -24,17 +24,27 @@
+class CompatibleTimeDelta(timedelta):
+ def __float__(self):
+ # Convert to float seconds.
+ return (self.days * 24 * 60 * 60 +
+ self.seconds + self.microseconds / 1.0e6)
+
+ def __int__(self):
+ return int(float(self))
+
+
def seconds(s):
- return timedelta(seconds=s)
+ return CompatibleTimeDelta(seconds=s)
def minutes(m):
- return timedelta(minutes=m)
+ return CompatibleTimeDelta(minutes=m)
def hours(h):
- return timedelta(hours=h)
+ return CompatibleTimeDelta(hours=h)
def days(d):
- return timedelta(days=d)
+ return CompatibleTimeDelta(days=d)
# Some convenient constants
@@ -714,7 +724,7 @@
# Qrunner defaults
#####
-# Which queues should the qrunner master watchdog spawn? add_qrunners() takes
+# Which queues should the qrunner master watchdog spawn? add_qrunner() takes
# one required argument, which is the name of the qrunner to start
# (capitalized and without the 'Runner' suffix). Optional second argument
# specifies the number of parallel processes to fork for each qrunner. If
=== modified file 'Mailman/LockFile.py'
--- a/Mailman/LockFile.py 2007-08-01 21:05:06 +0000
+++ b/Mailman/LockFile.py 2007-09-29 15:09:14 +0000
@@ -64,8 +64,8 @@
# Units are floating-point seconds.
DEFAULT_LOCK_LIFETIME = datetime.timedelta(seconds=15)
-# Allowable a bit of clock skew
-CLOCK_SLOP = datetime.timedelta(seconds=10)
+# Allowable a bit of clock skew, in seconds.
+CLOCK_SLOP = 10
# This is appropriate for Mailman, but you may want to change this if you're
# using this code outside Mailman.
log = logging.getLogger('mailman.locks')
=== modified file 'Mailman/Queue/BounceRunner.py'
--- a/Mailman/Queue/BounceRunner.py 2007-01-05 06:47:39 +0000
+++ b/Mailman/Queue/BounceRunner.py 2007-09-29 15:09:14 +0000
@@ -19,9 +19,9 @@
import os
import re
-import time
import cPickle
import logging
+import datetime
from email.MIMEMessage import MIMEMessage
from email.MIMEText import MIMEText
@@ -81,10 +81,11 @@
config.DATA_DIR, 'bounce-events-%05d.pck' % os.getpid())
self._bounce_events_fp = None
self._bouncecnt = 0
- self._nextaction = time.time() + config.REGISTER_BOUNCES_EVERY
+ self._nextaction = (datetime.datetime.now() +
+ config.REGISTER_BOUNCES_EVERY)
def _queue_bounces(self, listname, addrs, msg):
- today = time.localtime()[:3]
+ today = datetime.date.today()
if self._bounce_events_fp is None:
self._bounce_events_fp = open(self._bounce_events_file, 'a+b')
for addr in addrs:
@@ -129,7 +130,7 @@
self._register_bounces()
def _doperiodic(self):
- now = time.time()
+ now = datetime.datetime.now()
if self._nextaction > now or self._bouncecnt == 0:
return
# Let's go ahead and register the bounces we've got stored up
=== modified file 'Mailman/Queue/RetryRunner.py'
--- a/Mailman/Queue/RetryRunner.py 2007-01-19 04:38:06 +0000
+++ b/Mailman/Queue/RetryRunner.py 2007-09-29 15:09:14 +0000
@@ -38,4 +38,4 @@
def _snooze(self, filecnt):
# We always want to snooze
- time.sleep(self.SLEEPTIME)
+ time.sleep(float(self.SLEEPTIME))
=== modified file 'Mailman/Queue/Runner.py'
--- a/Mailman/Queue/Runner.py 2007-09-28 02:33:04 +0000
+++ b/Mailman/Queue/Runner.py 2007-09-29 15:09:14 +0000
@@ -229,9 +229,9 @@
based on this value. By default, we only snooze if there was nothing
to do last time around.
"""
- if filecnt or self.SLEEPTIME <= 0:
+ if filecnt or float(self.SLEEPTIME) <= 0:
return
- time.sleep(self.SLEEPTIME)
+ time.sleep(float(self.SLEEPTIME))
def _shortcircuit(self):
"""Return a true value if the individual file processing loop should
=== modified file 'Mailman/bin/mailmanctl.py'
--- a/Mailman/bin/mailmanctl.py 2007-07-18 15:46:44 +0000
+++ b/Mailman/bin/mailmanctl.py 2007-09-29 15:09:14 +0000
@@ -31,7 +31,6 @@
from Mailman import Utils
from Mailman import Version
from Mailman import loginit
-from Mailman.MailList import MailList
from Mailman.configuration import config
from Mailman.i18n import _
from Mailman.initialize import initialize
@@ -399,7 +398,7 @@
lock.refresh()
signal.alarm(Defaults.days(1))
signal.signal(signal.SIGALRM, sigalrm_handler)
- signal.alarm(Defaults.days(1))
+ signal.alarm(int(Defaults.days(1)))
# Set up a SIGHUP handler so that if we get one, we'll pass it along
# to all the qrunner children. This will tell them to close and
# reopen their log files
=== modified file 'Mailman/bin/make_instance.py'
--- a/Mailman/bin/make_instance.py 2007-08-05 04:32:09 +0000
+++ b/Mailman/bin/make_instance.py 2007-09-29 15:09:14 +0000
@@ -165,7 +165,9 @@
print >> sys.stderr, 'Ignoring unknown language codes:', \
SPACE.join(unknown_language)
languages = available_languages & enable_languages
- instantiate(opts.var_dir, opts.user, opts.group, languages, opts.force)
+ # We need an absolute path for var_dir.
+ var_dir = os.path.abspath(opts.var_dir)
+ instantiate(var_dir, opts.user, opts.group, languages, opts.force)
=== modified file 'Mailman/bin/withlist.py'
--- a/Mailman/bin/withlist.py 2007-08-05 04:32:09 +0000
+++ b/Mailman/bin/withlist.py 2007-09-29 15:09:14 +0000
@@ -21,7 +21,6 @@
import optparse
from Mailman import Errors
-from Mailman import MailList
from Mailman import Version
from Mailman import interact
from Mailman.configuration import config
@@ -83,14 +82,14 @@
General framework for interacting with a mailing list object.
There are two ways to use this script: interactively or programmatically.
-Using it interactively allows you to play with, examine and modify a MailList
-object from Python's interactive interpreter. When running interactively, a
-MailList object called 'm' will be available in the global namespace. It also
-loads the class MailList into the global namespace.
+Using it interactively allows you to play with, examine and modify a
+IMailinglist object from Python's interactive interpreter. When running
+interactively, a IMailingList object called 'm' will be available in the
+global namespace.
-Programmatically, you can write a function to operate on a MailList object,
-and this script will take care of the housekeeping (see below for examples).
-In that case, the general usage syntax is:
+Programmatically, you can write a function to operate on a IMailingList
+object, and this script will take care of the housekeeping (see below for
+examples). In that case, the general usage syntax is:
% bin/withlist [options] listname [args ...]
@@ -145,20 +144,20 @@
Note that if you use this option, you should explicitly call m.Save() before
exiting, since the interpreter's clean up procedure will not automatically
-save changes to the MailList object (but it will unlock the list)."""))
+save changes to the IMailingList object (but it will unlock the list)."""))
parser.add_option('-i', '--interactive',
default=None, action='store_true', help=_("""\
Leaves you at an interactive prompt after all other processing is complete.
This is the default unless the -r option is given."""))
parser.add_option('-r', '--run',
type='string', help=_("""\
-This can be used to run a script with the opened MailList object. This works
-by attempting to import 'module' (which must be in the directory containing
-withlist, or already be accessible on your sys.path), and then calling
-'callable' from the module. callable can be a class or function; it is called
-with the MailList object as the first argument. If additional args are given
-on the command line, they are passed as subsequent positional args to the
-callable.
+This can be used to run a script with the opened IMailingList object. This
+works by attempting to import'module' (which must be in the directory
+containing withlist, or already be accessible on your sys.path), and then
+calling 'callable' from the module. callable can be a class or function; it
+is called with the IMailingList object as the first argument. If additional
+args are given on the command line, they are passed as subsequent positional
+args to the callable.
Note that 'module.' is optional; if it is omitted then a module with the name
'callable' will be imported.
@@ -238,7 +237,8 @@
# Now go to interactive mode, perhaps
if opts.interactive:
if dolist:
- banner = _("The variable 'm' is the $listname MailList instance")
+ banner = _(
+ "The variable 'm' is the $listname mailing list")
else:
banner = interact.DEFAULT_BANNER
overrides = dict(m=LAST_MLIST, r=r)
--
https://code.launchpad.net/~mailman-coders/mailman/3.0
You are receiving this branch notification because you are subscribed to it.
To unsubscribe from this branch go to
https://code.launchpad.net/~mailman-coders/mailman/3.0/+subscription/mailman-checkins.
_______________________________________________
Mailman-checkins mailing list
[email protected]
Unsubscribe:
http://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org