ponymail-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject [incubator-ponymail] branch master updated: Allow use of indices.exists() method
Date Sat, 26 May 2018 12:12:04 GMT
This is an automated email from the ASF dual-hosted git repository.

sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ponymail.git


The following commit(s) were added to refs/heads/master by this push:
     new 43d8f05  Allow use of indices.exists() method
43d8f05 is described below

commit 43d8f0549ccb544862dcdc0448b7cf2bea0d50c4
Author: Sebb <sebb@apache.org>
AuthorDate: Sat May 26 13:12:03 2018 +0100

    Allow use of indices.exists() method
---
 tools/elastic.py | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/tools/elastic.py b/tools/elastic.py
index 8e813a2..a3a9c98 100755
--- a/tools/elastic.py
+++ b/tools/elastic.py
@@ -66,6 +66,8 @@ class Elastic:
             retry_on_timeout=True
             )
         self.dbVersion = None
+        # Mimic ES hierarchy: es.indices.xyz()
+        self.indices=_indices_wrap(self)
 
     def libraryVersion(self):
         return ES_VERSION
@@ -137,6 +139,21 @@ class Elastic:
         """
         return self.es.clear_scroll(*args, **kwargs)
 
+class _indices_wrap(object):
+    """
+        Wrapper for the ES indices methods we use
+    """
+    def __init__(self, parent):
+        self.es = parent.es
+
+    def exists(self, *args, **kwargs):
+        return self.es.indices.exists(*args, **kwargs)
+
 if __name__ == '__main__':
     es = Elastic()
-    print("Versions: Library: %d %s Engine: %d (%s)" % (es.libraryMajor(), es.libraryVersion(),
es.engineMajor(), es.engineVersion()))
\ No newline at end of file
+    print("Versions: Library: %d %s Engine: %d (%s)" % (es.libraryMajor(), es.libraryVersion(),
es.engineMajor(), es.engineVersion()))
+    try:
+        print(es.indices.exists(index='ponymail'))
+        print(es.indices.exists('test'))
+    except Exception as e:
+        print(type(e))

-- 
To stop receiving notification emails like this one, please contact
sebb@apache.org.

Mime
View raw message