return username:password@hostname:port
348695
def netloc(self):
        """"""
        s = ''
        prefix = ''
        if self.username:
            s += self.username
            prefix = '@'

        if self.password:
            s += ":{password}".format(password=self.password)
            prefix = '@'

        s += "{prefix}{hostloc}".format(prefix=prefix, hostloc=self.hostloc)
        return s
456174
def get_user_name():
    

    if sys.platform == 'win32':
        #user = os.getenv('USERPROFILE')
        user = os.getenv('USERNAME')
    else:
        user = os.getenv('LOGNAME')

    return user
559000
def getUserPassword(host='www.cadc-ccda.hia-iha.nrc-cnrc.gc.ca'):
    "
    if os.access(os.path.join(os.environ.get('HOME','/'),".netrc"),os.R_OK):
        auth=netrc.netrc().authenticators(host)
    else:
        auth=False
    if not auth:
        sys.stdout.write("CADC Username: ")
        username=sys.stdin.readline().strip('\n')
        password=getpass.getpass().strip('\n')
    else:
        username=auth[0]
        password=auth[2]
    return (username,password)
755554
def hostname(self):
        """"""
        try:
            return self.data.get('identity').get('host_name')
        except (KeyError, AttributeError):
            return self.device_status_simple('')
852510
def get_vcenter_vm_uuid_by_name(host, user, password, vm_name):
    
    vc = VcenterInterface(host, user, password)
    vmi = VmInterface(vc, vm_name)
    return vmi.get_instance_uuid()
567304
def get_user_password (self):
        
        if self.userinfo:
            # URL itself has authentication info
            return urllib.splitpasswd(self.userinfo)
        return self.aggregate.config.get_user_password(self.url)
555078
def _username():
    '''
    
    '''
    if pwd:
        username = pwd.getpwuid(os.getuid()).pw_name
    else:
        username = getpass.getuser()

    return username
274590
def _get_credentials(self):
        # type: () -> Optional[Tuple[str, str]]
        
        site = self.data[self.hdx_site]
        username = site.get('username')
        if username:
            return b64decode(username).decode('utf-8'), b64decode(site['password']).decode('utf-8')
        else:
            return None
105293
def password(name, default=None):
    

    prompt = name + (default and ' [%s]' % default or '')
    prompt += name.endswith('?') and ' ' or ': '
    while True:
        rv = getpass.getpass(prompt)
        if rv:
            return rv
        if default is not None:
            return default
1173765
def sudo!(*args)
      on roles(:all) do |host|
        key = "#{host.user}@#{host.hostname}"
        SSHKit::Sudo.password_cache[key] = "#{fetch(:password)}\n" # \n is enter
      end
      sudo(*args)
    end
224459
def user(self, username=None):
        
        if username is None:
            username = self.__getUsername()

        url = "%s/%s" % (self.root, username)
        return User(url=url,
                    securityHandler=self._securityHandler,
                    proxy_url=self._proxy_url,
                    proxy_port=self._proxy_port,
                    initalize=True)
326604
def pick_free_port(hostname=REDIRECT_HOST, port=0):
    
    import socket
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    try:
        s.bind((hostname, port))  # port=0 finds an open port
    except OSError as e:
        log.warning("Could not bind to %s:%s %s", hostname, port, e)
        if port == 0:
            print('Unable to find an open port for authentication.')
            raise AuthenticationException(e)
        else:
            return pick_free_port(hostname, 0)
    addr, port = s.getsockname()
    s.close()
    return port
813882
def _get_username_for_key(self):
        """"""
        response = self.client.get_access_key_last_used(
            AccessKeyId=self.compromised_resource['access_key_id']
        )
        username = response['UserName']
        return username
557406
def auth(username, password):
    
    def middleware(conn):
        conn.login(username, password)
    return middleware
930213
def parse_username_password_hostname(remote_url):
    
    assert remote_url
    assert ':' in remote_url

    if '@' in remote_url:
        username, hostname = remote_url.rsplit('@', 1)
    else:
        username, hostname = None, remote_url

    hostname, remote_path = hostname.split(':', 1)

    password = None
    if username and ':' in username:
        username, password = username.split(':', 1)

    assert hostname
    assert remote_path
    return username, password, hostname, remote_path
53627
def main():
   

   args = GetArgs()
   if args.password:
      password = args.password
   else:
      password = getpass.getpass(prompt='Enter password for host %s and '
                                        'user %s: ' % (args.host,args.user))

   context = None
   if hasattr(ssl, '_create_unverified_context'):
      context = ssl._create_unverified_context()
   si = SmartConnect(host=args.host,
                     user=args.user,
                     pwd=password,
                     port=int(args.port),
                     sslContext=context)
   if not si:
       print("Could not connect to the specified host using specified "
             "username and password")
       return -1

   atexit.register(Disconnect, si)

   obj = VmomiSupport.templateOf(args.type)(args.id, si._stub)
   print(json.dumps(obj, cls=VmomiSupport.VmomiJSONEncoder,
                    sort_keys=True, indent=4))
786387
def get_user_info(apikey, username, password):
    
    user = authenticate(username, password)
    site = Site.objects.get_current()
    return user_structure(user, site)