Since ES._check_server() checks whether the provided server is an instance of str, connecting with a unicode literal fails:
% ipython
Python 2.7.6 (default, Feb 26 2014, 00:34:35)
[...]
In [1]: from __future__ import unicode_literals
In [2]: from pyes import ES
In [3]: server = 'localhost:9200'
In [4]: type(server)
Out[4]: unicode
In [5]: es = ES(server)
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-5-5ac2eb20e0e0> in <module>()
----> 1 es = ES(server)
/media/projects/pyes.git/pyes/es.pyc in __init__(self, server, timeout, bulk_size, encoder, decoder, max_retries, default_indices, default_types, log_curl, dump_curl, model, basic_auth, raise_on_bulk_item_failure, document_object_field, bulker_class, cert_reqs)
225 self._check_servers()
226 #init connections
--> 227 self._init_connection()
228
229
/media/projects/pyes.git/pyes/es.pyc in _init_connection(self)
299 #detect connectiontype
300 if not self.servers:
--> 301 raise RuntimeError("No server defined")
302
303 server = random.choice(self.servers)
RuntimeError: No server defined
In [6]:
Since
ES._check_server()
checks whether the provided server is an instance ofstr
, connecting with aunicode
literal fails: