<s> from . cursor import Cursor <EOL> from . exceptions import ProgrammingError , ConnectionError <EOL> from . http import Client <EOL> from . blob import BlobContainer <EOL> from distutils . version import StrictVersion <EOL> class Connection ( object ) : <EOL> def __init__ ( self , servers = None , timeout = None , client = None , <EOL> verify_ssl_cert = False , ca_cert = None , error_trace = False ) : <EOL> if client : <EOL> self . client = client <EOL> else : <EOL> self . client = Client ( servers , <EOL> timeout = timeout , <EOL> verify_ssl_cert = verify_ssl_cert , <EOL> ca_cert = ca_cert , <EOL> error_trace = error_trace ) <EOL> self . lowest_server_version = self . _lowest_server_version ( ) <EOL> self . _closed = False <EOL> def cursor ( self ) : <EOL> """<STR_LIT>""" <EOL> if not self . _closed : <EOL> return Cursor ( self ) <EOL> else : <EOL> raise ProgrammingError ( "<STR_LIT>" ) <EOL> def close ( self ) : <EOL> """<STR_LIT>""" <EOL> self . _closed = True <EOL> def commit ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . _closed : <EOL> raise ProgrammingError ( "<STR_LIT>" ) <EOL> def get_blob_container ( self , container_name ) : <EOL> """<STR_LIT>""" <EOL> return BlobContainer ( container_name , self ) <EOL> def _lowest_server_version ( self ) : <EOL> lowest = None <EOL> for server in self . client . active_servers : <EOL> try : <EOL> _ , _ , version = self . client . server_infos ( server ) <EOL> version = StrictVersion ( version ) <EOL> except ( ValueError , ConnectionError ) : <EOL> continue <EOL> if not lowest or version < lowest : <EOL> lowest = version <EOL> return lowest or StrictVersion ( '<STR_LIT>' ) <EOL> def __repr__ ( self ) : <EOL> return '<STR_LIT>' . format ( repr ( self . client ) ) <EOL> def connect ( servers = None , timeout = None , client = None , <EOL> verify_ssl_cert = False , ca_cert = None , error_trace = False ) : <EOL> """<STR_LIT>""" <EOL> return Connection ( servers = servers , timeout = timeout , client = client , <EOL> verify_ssl_cert = verify_ssl_cert , ca_cert = ca_cert , <EOL> error_trace = error_trace ) </s>
