def get_gateway(host, port, cache, replace=False):
 from fabric.state import env, output
 sock = None
 proxy_command = ssh_config().get('proxycommand', None)
 if env.gateway:
  gateway = normalize_to_string(env.gateway)
  if (replace or (gateway not in cache)):
   if output.debug:
    print ('Creating new gateway connection to %r' % gateway)
   cache[gateway] = connect(*(normalize(gateway) + (cache, False)))
  sock = direct_tcpip(dict.__getitem__(cache, gateway), host, port)
 elif proxy_command:
  sock = ssh.ProxyCommand(proxy_command)
 return sock

def get_gateway ( host , port , cache , replace = False ) : from fabric . state import env , output sock = None proxy_command = ssh_config ( ) . get ( 'proxycommand' , None ) if env . gateway : gateway = normalize_to_string ( env . gateway ) if ( replace or ( gateway not in cache ) ) : if output . debug : print ( 'Creating new gateway connection to %r' % gateway ) cache [ gateway ] = connect ( * ( normalize ( gateway ) + ( cache , False ) ) ) sock = direct_tcpip ( dict . __getitem__ ( cache , gateway ) , host , port ) elif proxy_command : sock = ssh . ProxyCommand ( proxy_command ) return sock
create and return a gateway socket .