[mhonarc] archive.py: incomplete rewrite to Python



commit 6ca1e61bdc7fbce6b04a862b906de0c51cb71eb8
Author: Olav Vitters <olav vitters nl>
Date:   Mon Feb 11 20:55:22 2013 +0100

    archive.py: incomplete rewrite to Python

 archive.py |   96 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 96 insertions(+), 0 deletions(-)
---
diff --git a/archive.py b/archive.py
new file mode 100755
index 0000000..b26febf
--- /dev/null
+++ b/archive.py
@@ -0,0 +1,96 @@
+#!/usr/bin/python
+
+import os
+import os.path
+import sys
+
+
+print >>sys.stderr, "INCOMPLETE"
+sys.exit(1)
+
+class Archiver
+    PUBLIC_ARCHIVE_DIR = "/var/lib/mailman/archives/public"
+    PUBLIC_RCFILE = "/home/admin/mhonarc/public-rc/base.rc"
+    PRIVATE_ARCHIVE_DIR = "/var/lib/mailman/archives/private"
+    PRIVATE_RCFILE = "/home/admin/mhonarc/private-rc/base.rc"
+
+
+    def __init__(self, listname, private=False, debug=False):
+
+        self.listname = listname
+        self.private = private
+        self.debug = debug
+
+        self.olddir = None
+        self.tmpname = 'XXX'
+
+        self.start_time = None
+        self.end_time = None
+
+    def output(self, last):
+        tmpname = self.tmpname
+
+        path = os.path.join(self.PRIVATE_ARCHIVE_DIR, self.listname, self.olddir)
+
+        if not os.path.exists(path):
+            os.makedirs(path, 0755)
+
+        rcfile = self.PRIVATE_RCFILE if self.private else self.PUBLIC_RCFILE
+
+#        system (<<EOT);
+#        mhonarc -umask 022 -rcfile $rcfile -add -outdir $dir $tmpname -definevar "ARCHDATE=$self->{olddir} LISTNAME=$self->{listname}" >> /var/log/mailman/archive 2>&1Â
+#        EOT
+
+        if os.path.exists("%s.txt" % path):
+            #system ("cat < $tmpname >> $dir.txt");
+        else:
+            #system ("gzip -c < $tmpname >> $dir.txt.gz");
+
+        if last:
+            os.remove(self.tmpname)
+
+            make_index(self.listname, self.private)
+
+            # XXX - if public add symlink from private to public
+
+        else:
+            # XXX - reopen tmpname
+
+
+    def handle_message(self, msg):
+        
+        received_texts = msg.get_all('Received')
+
+        received_time = None
+
+        # XXX - parse received headers
+
+        if received_time is not None:
+            if self.start_time and received_time < self.start_time:
+                return False
+
+            if self.end_time and received_time > self.end_time:
+                return False
+
+            path = received_time.strftime("%Y-%B")
+
+            if self.olddir is not None and self.olddir != path:
+                # XXX wtf
+                self.output(False)
+
+            self.olddir = path
+            self.last_time = received_time
+            self.last_parseable_time = received_time_text
+
+
+
+
+
+
+
+
+
+
+
+
+


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]