def _get_connection_from_url(self, url, timeout, **kwargs):
url = self._decode_url(url, "<STR_LIT>")<EOL>if url.scheme == '<STR_LIT:http>' or url.scheme == '<STR_LIT>':<EOL><INDENT>return HttpConnection(url.geturl(), timeout=timeout, **kwargs)<EOL><DEDENT>else:<EOL><INDENT>if sys.version_info[<NUM_LIT:0>] > <NUM_LIT:2>:<EOL><INDENT>raise ValueError("<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>try:<EOL><INDENT>from thrift_connection import ThriftConnection<EOL><DEDENT>except ImportError:<EOL><INDENT>raise ImportError("<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>return ThriftConnection(url.hostname, url.port,<EOL>timeout=timeout, **kwargs)<EOL><DEDENT>
Returns a connection object given a string url