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/07 00:00:44 UTC
incubator-ponymail git commit: import-mbox.py keeps rechecking if the
index exists
Repository: incubator-ponymail
Updated Branches:
refs/heads/master ce6810c56 -> bade1677e
import-mbox.py keeps rechecking if the index exists
This fixes #233
Project: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/commit/bade1677
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/tree/bade1677
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/diff/bade1677
Branch: refs/heads/master
Commit: bade1677e3d350be9d906381b0ccf137764da8b9
Parents: ce6810c
Author: Sebb <se...@apache.org>
Authored: Mon Nov 7 00:00:05 2016 +0000
Committer: Sebb <se...@apache.org>
Committed: Mon Nov 7 00:00:05 2016 +0000
----------------------------------------------------------------------
tools/import-mbox.py | 22 +++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/bade1677/tools/import-mbox.py
----------------------------------------------------------------------
diff --git a/tools/import-mbox.py b/tools/import-mbox.py
index 0171f54..7ccdcea 100755
--- a/tools/import-mbox.py
+++ b/tools/import-mbox.py
@@ -110,13 +110,6 @@ class BulkThread(Thread):
def insert(self):
global config
sys.stderr.flush()
- # thread code writes exceptions to stderr so capture and log a summary ourselves
- try:
- if not self.xes.indices.exists(dbname):
- self.xes.indices.create(index = dbname)
- except Exception as err:
- print("Warning: Could not create the index %s: %s" % (dbname,err))
- return
js_arr = []
i = 0
@@ -422,6 +415,21 @@ if args.timeout:
timeout = args.timeout[0]
baddies = 0
+# No point continuing if the index does not exist
+print("Checking that the database index %s exists ... " % dbname, end='')
+
+# elasticsearch logs lots of warnings on retries/connection failure
+import logging
+logging.getLogger("elasticsearch").setLevel(logging.ERROR)
+try:
+ if not es.indices.exists(dbname):
+ print("\nError: the index '%s' does not exist!" % (dbname))
+ sys.exit(1)
+except Exception as err:
+ print("\nError: unable to check if the index %s exists!: %s" % (dbname, err))
+ sys.exit(1)
+
+print("Database exists OK")
def globDir(d):
dirs = [ f for f in listdir(d) if isdir(join(d,f)) ]