diff options
| -rw-r--r-- | Mailman/Defaults.py | 20 | ||||
| -rw-r--r-- | Mailman/LockFile.py | 4 | ||||
| -rw-r--r-- | Mailman/Queue/BounceRunner.py | 9 | ||||
| -rw-r--r-- | Mailman/Queue/RetryRunner.py | 2 | ||||
| -rw-r--r-- | Mailman/Queue/Runner.py | 4 | ||||
| -rw-r--r-- | Mailman/bin/mailmanctl.py | 3 | ||||
| -rw-r--r-- | Mailman/bin/make_instance.py | 4 | ||||
| -rw-r--r-- | Mailman/bin/withlist.py | 34 |
8 files changed, 46 insertions, 34 deletions
diff --git a/Mailman/Defaults.py b/Mailman/Defaults.py index 592d6d0ff..8e55057e6 100644 --- a/Mailman/Defaults.py +++ b/Mailman/Defaults.py @@ -24,17 +24,27 @@ from Mailman.constants import * +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 @@ MAX_AUTORESPONSES_PER_DAY = 10 # 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 diff --git a/Mailman/LockFile.py b/Mailman/LockFile.py index 33008e92b..9323b4895 100644 --- a/Mailman/LockFile.py +++ b/Mailman/LockFile.py @@ -64,8 +64,8 @@ import traceback # 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') diff --git a/Mailman/Queue/BounceRunner.py b/Mailman/Queue/BounceRunner.py index d398e1b4a..6ce7ef393 100644 --- a/Mailman/Queue/BounceRunner.py +++ b/Mailman/Queue/BounceRunner.py @@ -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 @@ class BounceMixin: 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 @@ class BounceMixin: 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 diff --git a/Mailman/Queue/RetryRunner.py b/Mailman/Queue/RetryRunner.py index 9ecde0419..33e9459b5 100644 --- a/Mailman/Queue/RetryRunner.py +++ b/Mailman/Queue/RetryRunner.py @@ -38,4 +38,4 @@ class RetryRunner(Runner): def _snooze(self, filecnt): # We always want to snooze - time.sleep(self.SLEEPTIME) + time.sleep(float(self.SLEEPTIME)) diff --git a/Mailman/Queue/Runner.py b/Mailman/Queue/Runner.py index 9fb5434cc..958e11e6c 100644 --- a/Mailman/Queue/Runner.py +++ b/Mailman/Queue/Runner.py @@ -229,9 +229,9 @@ class Runner: 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 diff --git a/Mailman/bin/mailmanctl.py b/Mailman/bin/mailmanctl.py index 78ae0c8e8..f6190f685 100644 --- a/Mailman/bin/mailmanctl.py +++ b/Mailman/bin/mailmanctl.py @@ -31,7 +31,6 @@ from Mailman import LockFile 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 @@ def main(): 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 diff --git a/Mailman/bin/make_instance.py b/Mailman/bin/make_instance.py index 8ec0d13b5..424b7f38a 100644 --- a/Mailman/bin/make_instance.py +++ b/Mailman/bin/make_instance.py @@ -165,7 +165,9 @@ def main(): 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) diff --git a/Mailman/bin/withlist.py b/Mailman/bin/withlist.py index ba643af81..f6c66a703 100644 --- a/Mailman/bin/withlist.py +++ b/Mailman/bin/withlist.py @@ -21,7 +21,6 @@ import atexit 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 @@ def parseargs(): 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 @@ read-only operations). You can always lock the file after the fact by typing 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 @@ def main(): # 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) |
