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/10/31 17:07:44 UTC

incubator-ponymail git commit: Don't refetch dbname unnecessarily

Repository: incubator-ponymail
Updated Branches:
  refs/heads/master 3d0e41976 -> c5181003c


Don't refetch dbname unnecessarily

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

Branch: refs/heads/master
Commit: c5181003c981e74fd5bd0cde7f38a47c91e1186d
Parents: 3d0e419
Author: Sebb <se...@apache.org>
Authored: Mon Oct 31 17:07:33 2016 +0000
Committer: Sebb <se...@apache.org>
Committed: Mon Oct 31 17:07:33 2016 +0000

----------------------------------------------------------------------
 tools/import-mbox.py | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/c5181003/tools/import-mbox.py
----------------------------------------------------------------------
diff --git a/tools/import-mbox.py b/tools/import-mbox.py
index 4c14db0..2018c32 100755
--- a/tools/import-mbox.py
+++ b/tools/import-mbox.py
@@ -122,9 +122,8 @@ class BulkThread(Thread):
     def insert(self):
         global config
         sys.stderr.flush()
-        iname = config.get("elasticsearch", "dbname")
-        if not self.xes.indices.exists(iname):
-            self.xes.indices.create(index = iname)
+        if not self.xes.indices.exists(dbname):
+            self.xes.indices.create(index = dbname)
 
         js_arr = []
         i = 0
@@ -135,7 +134,7 @@ class BulkThread(Thread):
             js_arr.append({
                 '_op_type': 'index',
                 '_consistency': self.wc,
-                '_index': iname,
+                '_index': dbname,
                 '_type': self.dtype,
                 '_id': js['mid'],
                 'doc': js,
@@ -265,9 +264,8 @@ class SlurpThread(Thread):
                 
                 # If --dedup is active, try to filter out any messages that already exist
                 if json and dedup and message.get('message-id', None):
-                    iname = config.get("elasticsearch", "dbname")
                     res = es.search(
-                        index=iname,
+                        index=dbname,
                         doc_type="mbox",
                         size = 1,
                         body = {
@@ -300,11 +298,10 @@ class SlurpThread(Thread):
                     ja.append(json)
                     jas.append(json_source)
                     if contents:
-                        iname = config.get("elasticsearch", "dbname")
                         if not args.dry:
                             for key in contents:
                                 es.index(
-                                    index=iname,
+                                    index=dbname,
                                     doc_type="attachment",
                                     id=key,
                                     body = {