You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ponymail.apache.org by se...@apache.org on 2016/11/22 09:58:20 UTC

incubator-ponymail git commit: import-mbox dry run should exercise as much as possible of the code

Repository: incubator-ponymail
Updated Branches:
  refs/heads/master 28ee7e8a1 -> b07491cd3


import-mbox dry run should exercise as much as possible of the code

This fixes #258

Project: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/commit/b07491cd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/tree/b07491cd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/diff/b07491cd

Branch: refs/heads/master
Commit: b07491cd35d400326269e819fcc0518e647641f3
Parents: 28ee7e8
Author: Sebb <se...@apache.org>
Authored: Tue Nov 22 09:33:55 2016 +0000
Committer: Sebb <se...@apache.org>
Committed: Tue Nov 22 09:33:55 2016 +0000

----------------------------------------------------------------------
 tools/import-mbox.py | 29 ++++++++++++++---------------
 1 file changed, 14 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/b07491cd/tools/import-mbox.py
----------------------------------------------------------------------
diff --git a/tools/import-mbox.py b/tools/import-mbox.py
index 790e961..37e2d4f 100755
--- a/tools/import-mbox.py
+++ b/tools/import-mbox.py
@@ -132,11 +132,12 @@ class BulkThread(Thread):
                 'doc': js,
                 '_source': js
             })
-        try:
-            helpers.bulk(self.xes, js_arr)
-        except Exception as err:
-            print("%s: Warning: Could not bulk insert: %s into %s" % (self.id,err,self.dtype))
-#         print("%s: Inserted %u entries into %s" % (self.id, len(js_arr),self.dtype))
+        if not args.dry:
+            try:
+                helpers.bulk(self.xes, js_arr)
+            except Exception as err:
+                print("%s: Warning: Could not bulk insert: %s into %s" % (self.id,err,self.dtype))
+#             print("%s: Inserted %u entries into %s" % (self.id, len(js_arr),self.dtype))
 
 
 class SlurpThread(Thread):
@@ -309,16 +310,14 @@ class SlurpThread(Thread):
                                     }
                                 )
                     if len(ja) >= 40:
-                        if not args.dry:
-                            bulk = BulkThread()
-                            bulk.assign(self.name, ja, es, 'mbox')
-                            bulk.insert()
+                        bulk = BulkThread()
+                        bulk.assign(self.name, ja, es, 'mbox')
+                        bulk.insert()
                         ja = []
                         
-                        if not args.dry:
-                            bulks = BulkThread()
-                            bulks.assign(self.name, jas, es, 'mbox_source')
-                            bulks.insert()
+                        bulks = BulkThread()
+                        bulks.assign(self.name, jas, es, 'mbox_source')
+                        bulks.insert()
                         jas = []
                 else:
                     self.printid("Failed to parse: Return=%s Message-Id=%s" % (message.get('Return-Path'), message.get('Message-Id')))
@@ -336,13 +335,13 @@ class SlurpThread(Thread):
                 
             y += count
             baddies += bad
-            if len(ja) > 0 and not args.dry:
+            if len(ja) > 0:
                 bulk = BulkThread()
                 bulk.assign(self.name, ja, es, 'mbox')
                 bulk.insert()
             ja = []
             
-            if len(jas) > 0 and not args.dry:
+            if len(jas) > 0:
                 bulks = BulkThread()
                 bulks.assign(self.name, jas, es, 'mbox_source')
                 bulks.insert()