summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorviega1998-05-31 04:53:34 +0000
committerviega1998-05-31 04:53:34 +0000
commit1a0e293a4f9dc6fa9372df4c7599d7b6c9a99053 (patch)
tree1ca3a84927832ae02092226cc8bb434ade703852
parentae85f8ba29a6f469340a842d17208b700609f6bf (diff)
downloadmailman-1a0e293a4f9dc6fa9372df4c7599d7b6c9a99053.tar.gz
mailman-1a0e293a4f9dc6fa9372df4c7599d7b6c9a99053.tar.zst
mailman-1a0e293a4f9dc6fa9372df4c7599d7b6c9a99053.zip
This script is meant to be called by cron, and trys to gate any new
news to mailing lists.
-rwxr-xr-xcron/gate_news48
1 files changed, 48 insertions, 0 deletions
diff --git a/cron/gate_news b/cron/gate_news
new file mode 100755
index 000000000..e9c159e66
--- /dev/null
+++ b/cron/gate_news
@@ -0,0 +1,48 @@
+#! /usr/bin/env python
+#
+# Copyright (C) 1998 by the Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+import paths
+import maillist, mm_cfg, mm_utils, marshal, os
+
+names = mm_utils.list_names()
+try:
+ file = open(os.path.join(mm_cfg.DATA_DIR, "gate_watermarks"), "r")
+ watermarks = marshal.load(file)
+except IOError, (x,y):
+ if x <> 2:
+ raise IOError, (x, y)
+ watermarks = {}
+
+for name in names:
+ if watermarks.has_key(name):
+ wm = watermarks[name]
+ else:
+ wm = 0
+ # Save the current state to .last, in case we crash while writing out,
+ # and corrupt the file.
+ list = maillist.MailList(name)
+ file = open(os.path.join(mm_cfg.DATA_DIR, "gate_watermarks.last"), "w")
+ marshal.dump(watermarks, file)
+ file.close()
+ watermarks[name] = list.PollNewsGroup(wm)
+ # Save after every newsgroup... should probably save after every post.
+ # Reason being, want to make sure in case of a system crash or something,
+ # The same messages don't get gated multiple times.
+ file = open(os.path.join(mm_cfg.DATA_DIR, "gate_watermarks"), "w")
+ marshal.dump(watermarks, file)
+ file.close() \ No newline at end of file