def __init__(self,<EOL>name,<EOL>crate_home,<EOL>crate_config=None,<EOL>port=None,<EOL>keepRunning=False,<EOL>transport_port=None,<EOL>crate_exec=None,<EOL>cluster_name=None,<EOL>host="<STR_LIT:127.0.0.1>",<EOL>settings=None,<EOL>verbose=False,<EOL>env=None):
self.__name__ = name<EOL>if settings and isinstance(settings, dict):<EOL><INDENT>self.http_url = http_url_from_host_port(settings.get('<STR_LIT>', host),<EOL>settings.get('<STR_LIT>', port))<EOL><DEDENT>else:<EOL><INDENT>self.http_url = http_url_from_host_port(host, port)<EOL><DEDENT>self.process = None<EOL>self.verbose = verbose<EOL>self.env = env or {}<EOL>self.env.setdefault('<STR_LIT>', '<STR_LIT:true>')<EOL>self._stdout_consumers = []<EOL>self.conn_pool = urllib3.PoolManager(num_pools=<NUM_LIT:1>)<EOL>crate_home = os.path.abspath(crate_home)<EOL>if crate_exec is None:<EOL><INDENT>start_script = '<STR_LIT>' if sys.platform == '<STR_LIT:win32>' else '<STR_LIT>'<EOL>crate_exec = os.path.join(crate_home, '<STR_LIT>', start_script)<EOL><DEDENT>if crate_config is None:<EOL><INDENT>crate_config = os.path.join(crate_home, '<STR_LIT>', '<STR_LIT>')<EOL><DEDENT>elif (os.path.isfile(crate_config) and<EOL>os.path.basename(crate_config) != '<STR_LIT>'):<EOL><INDENT>raise ValueError(CRATE_CONFIG_ERROR)<EOL><DEDENT>if cluster_name is None:<EOL><INDENT>cluster_name = "<STR_LIT>".format(port or '<STR_LIT>')<EOL><DEDENT>settings = self.create_settings(crate_config,<EOL>cluster_name,<EOL>name,<EOL>host,<EOL>port or '<STR_LIT>',<EOL>transport_port or '<STR_LIT>',<EOL>settings)<EOL>start_cmd = (crate_exec, ) + tuple(["<STR_LIT>" % ((key, str(value).lower()) if type(value) == bool else (key, value))<EOL>for key, value in settings.items()])<EOL>self._wd = wd = os.path.join(CrateLayer.tmpdir, '<STR_LIT>', name)<EOL>self.start_cmd = start_cmd + ('<STR_LIT>' % wd,)<EOL>
:param name: layer name, is also used as the cluser name
:param crate_home: path to home directory of the crate installation
:param port: port on which crate should run
:param transport_port: port on which transport layer for crate should
                       run
:param crate_exec: alternative executable command
:param crate_config: alternative crate config file location.
                     Must be a directory or a file named 'crate.yml'
:param cluster_name: the name of the cluster to join/build. Will be
                     generated automatically if omitted.
:param host: the host to bind to. defaults to 'localhost'
:param settings: further settings that do not deserve a keyword
                 argument will be prefixed with ``es.``.
:param verbose: Set the log verbosity of the test layer
:param env: Set environment variables.