Author: rgardler
Date: Wed Nov 17 02:35:22 2010
New Revision: 1035905

URL: http://svn.apache.org/viewvc?rev=1035905&view=rev
Log:
Commit add a -s switch to display some basic statistical information

Modified:
    labs/agora/src/python/process.py

Modified: labs/agora/src/python/process.py
URL: 
http://svn.apache.org/viewvc/labs/agora/src/python/process.py?rev=1035905&r1=1035904&r2=1035905&view=diff
==============================================================================
--- labs/agora/src/python/process.py (original)
+++ labs/agora/src/python/process.py Wed Nov 17 02:35:22 2010
@@ -24,6 +24,9 @@ Where OPTIONS is one or more of:
 
     -h
         show usage and exit
+    -s
+        display stats from the history file. These stats describe processing 
+        that has been carried out in the past.
     -m PATH
         set the path to the directory that contains the mailbox to process
         [default to './mail']
@@ -123,7 +126,7 @@ I'm using the info provided by D.J. Bern
 def process(read,write):
 
     total = valid = invalid = error = missing_date = missing_address = 
missing_msgID = missing_backlink = 0
-    
+        
     if read[-3:] == '.gz':
         input = gzip.open(read,'r')
     else:
@@ -181,7 +184,7 @@ def process(read,write):
         
     output.close()
     input.close()
-
+    
     return (total, valid, invalid, error, missing_date, missing_address, 
missing_msgID, missing_backlink)
             
 #-----------------------------------------------------------------------# 
@@ -226,6 +229,7 @@ def crawl(history,archives,input_path,ou
         else:
             if loud:
                 print "Ignoring", input
+
 #-----------------------------------------------------------------------# 
 
 def usage(code, msg=''):
@@ -245,7 +249,7 @@ def main():
     global loud, force
 
     try:
-        opts, args = getopt.getopt(sys.argv[1:], 'hfqvd:m:p:')
+        opts, args = getopt.getopt(sys.argv[1:], 'hsfqvd:m:p:')
     except getopt.error, msg:
         usage(2, msg)
 
@@ -256,6 +260,9 @@ def main():
     for opt, arg in opts:
         if opt == '-h':
             usage(0)
+        if opt == '-s':
+            display_stats()
+            sys.exit(0)
         elif opt == "-q":
             loud = False
         elif opt == "-f":
@@ -293,6 +300,27 @@ def main():
 
 #-----------------------------------------------------------------------# 
 
+def display_stats():
+    history = load_history()
+    for file in history:
+        last_modified = history[file][0]
+        stats = history[file][1]
+        total = stats[0]
+        valid = stats[1]
+        invalid = stats[2]
+        error = stats[3]
+        missing_date = stats[4]
+        missing_address = stats[5]
+        missing_msgID = stats[6]
+        missing_backlink = stats[7]
+        
+        print file
+        print "Total emails", total
+        print "Not in reply-to", missing_backlink
+        print
+        
+#-----------------------------------------------------------------------# 
+
 if __name__ == "__main__":
     main()
 



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to