summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbwarsaw2001-06-04 17:21:25 +0000
committerbwarsaw2001-06-04 17:21:25 +0000
commit558926b49476726d77b83ea5d13179de25c404c8 (patch)
treee2fb7f9f4956c0a1fed920d54f14dca564696258
parent041820d0cedb23ea41fd3246cf3452a7c6107ca3 (diff)
downloadmailman-558926b49476726d77b83ea5d13179de25c404c8.tar.gz
mailman-558926b49476726d77b83ea5d13179de25c404c8.tar.zst
mailman-558926b49476726d77b83ea5d13179de25c404c8.zip
A few more updates to get this script working. Specifically,
main(): Only lock the list during the NumRequestsPending() call. We don't actually change the state of the list data, but the ListAdmin interface requires the list to be locked even to read (yes, this is bogus). Also, fix the _() marked string to use the required auto-interpolation. pending_requests(): Mark some additional strings for i18n. Also, pending subscription requests include the language in the unpacked data (fix the tuple unpacking).
-rwxr-xr-xcron/checkdbs47
1 files changed, 27 insertions, 20 deletions
diff --git a/cron/checkdbs b/cron/checkdbs
index 4086d9e7c..cb093abb5 100755
--- a/cron/checkdbs
+++ b/cron/checkdbs
@@ -28,6 +28,7 @@ from Mailman import mm_cfg
from Mailman import Utils
from Mailman import MailList
from Mailman import Message
+from Mailman import i18n
# Work around known problems with some RedHat cron daemons
import signal
@@ -35,6 +36,9 @@ signal.signal(signal.SIGCHLD, signal.SIG_DFL)
NL = '\n'
+_ = i18n._
+i18n.set_language(mm_cfg.DEFAULT_SERVER_LANGUAGE)
+
def main():
@@ -43,24 +47,26 @@ def main():
mlist = MailList.MailList(name)
try:
count = mlist.NumRequestsPending()
- if count:
- text = Utils.maketext(
- 'checkdbs.txt',
- {'count' : count,
- 'host_name': mlist.host_name,
- 'adminDB' : mlist.GetScriptURL('admindb', absolute=1),
- 'real_name': mlist.real_name,
- }, mlist.preferred_language)
- text = text + '\n' + pending_requests(mlist)
- subject = _('%d %s moderator request(s) waiting' % (
- count, mlist.real_name))
- admin = mlist.GetAdminEmail()
- msg = Message.UserNotification(admin, admin, subject, text)
- msg.send(mlist, **{'tomoderators': 1})
- mlist.Save()
+ # Don't save the list since we've done nothing to modify its state
finally:
mlist.Unlock()
+ if count:
+ i18n.set_language(mlist.preferred_language)
+ realname = mlist.real_name
+ text = Utils.maketext(
+ 'checkdbs.txt',
+ {'count' : count,
+ 'host_name': mlist.host_name,
+ 'adminDB' : mlist.GetScriptURL('admindb', absolute=1),
+ 'real_name': realname,
+ }, mlist=mlist)
+ text = text + '\n' + pending_requests(mlist)
+ subject = _('%(count)d %(realname)s moderator request(s) waiting')
+ admin = mlist.GetAdminEmail()
+ msg = Message.UserNotification(admin, admin, subject, text)
+ msg.send(mlist, **{'tomoderators': 1})
+
def pending_requests(mlist):
@@ -68,14 +74,14 @@ def pending_requests(mlist):
first = 1
for id in mlist.GetSubscriptionIds():
if first:
- pending.append('Pending subscriptions:')
+ pending.append(_('Pending subscriptions:'))
first = 0
- when, addr, passwd, digest = mlist.GetRecord(id)
+ when, addr, passwd, digest, lang = mlist.GetRecord(id)
pending.append(' %s %s' % (addr, time.ctime(when)))
first = 1
for id in mlist.GetHeldMessageIds():
if first:
- pending.append('\nPending posts:')
+ pending.append(_('\nPending posts:'))
first = 0
info = mlist.GetRecord(id)
if len(info) == 5:
@@ -83,8 +89,9 @@ def pending_requests(mlist):
when, sender, subject, reason, text = mlist.GetRecord(id)
else:
when, sender, subject, reason, text, msgdata = mlist.GetRecord(id)
- pending.append(' From: %s on %s\n Cause: %s' %
- (sender, time.ctime(when), reason))
+ date = time.ctime(when)
+ pending.append(_(
+ ' From: %(sender)s on %(date)s\n Cause: %(reason)s'))
pending.append('')
return NL.join(pending)