Gets the NDEx credentials from the dict, or tries the environment if None
768432
def get_default_ndex_cred(ndex_cred):
    """"""
    if ndex_cred:
        username = ndex_cred.get('user')
        password = ndex_cred.get('password')

        if username is not None and password is not None:
            return username, password

    username = get_config('NDEX_USERNAME')
    password = get_config('NDEX_PASSWORD')

    return username, password
1062667
def pull_env_credential(env, param, value):
    
    rex = "USE_KEYRING\[([\x27\x22])(.*)\\1\]"

    # This is the old-style, per-environment keyring credential
    if value == "USE_KEYRING":
        username = utils.assemble_username(env, param)

    # This is the new-style, global keyring credential that can be applied
    # to multiple environments
    else:
        global_identifier = re.match(rex, value).group(2)
        username = utils.assemble_username('global', global_identifier)

    return (username, password_get(username))
52899
def get_mysql_credentials(cfg_file):
    """"""

    try:
        parser = ConfigParser.ConfigParser()
        cfg_fp = open(cfg_file)
        parser.readfp(cfg_fp)
        cfg_fp.close()
    except ConfigParser.NoOptionError:
        cfg_fp.close()
        print('Failed to find mysql connections credentials.')
        sys.exit(1)
    except IOError:
        print('ERROR: Cannot open %s.', cfg_file)
        sys.exit(1)

    value = parser.get('dfa_mysql', 'connection')

    try:
        # Find location of pattern in connection parameter as shown below:
        # http://username:password@host/databasename?characterset=encoding'
        sobj = re.search(r"(://).*(@).*(/).*(\?)", value)

        # The list parameter contains:
        # indices[0], is the index of '://'
        # indices[1], is the index of '@'
        # indices[2], is the index of '/'
        # indices[3], is the index of '?'
        indices = [sobj.start(1), sobj.start(2), sobj.start(3), sobj.start(4)]

        # Get the credentials
        cred = value[indices[0] + 3:indices[1]].split(':')

        # Get the host name
        host = value[indices[1] + 1:indices[2]]

        # Get the database name
        db_name = value[indices[2] + 1:indices[3]]

        # Get the character encoding
        charset = value[indices[3] + 1:].split('=')[1]

        return cred[0], cred[1], host, db_name, charset
    except (ValueError, IndexError, AttributeError):
        print('Failed to find mysql connections credentials.')
        sys.exit(1)
344529
def get_xdg_env(env_name, fallback):
    
    env = os.environ.get(env_name)
    return env if env else fallback
1005568
def get_credentials(self):
        
        return ReadOnlyCredentials(
            self.access_token, self.client_id, self.client_secret,
            self.refresh_token
        )
285779
def _get_gae_credentials():
    """"""
    # While this library is normally bundled with app_engine, there are
    # some cases where it's not available, so we tolerate ImportError.
    try:
        import google.auth.app_engine as app_engine
    except ImportError:
        return None, None

    try:
        credentials = app_engine.Credentials()
        project_id = app_engine.get_project_id()
        return credentials, project_id
    except EnvironmentError:
        return None, None
752561
def _get_gce_credentials(request=None):
    """"""
    # Ping requires a transport, but we want application default credentials
    # to require no arguments. So, we'll use the _http_client transport which
    # uses http.client. This is only acceptable because the metadata server
    # doesn't do SSL and never requires proxies.

    # While this library is normally bundled with compute_engine, there are
    # some cases where it's not available, so we tolerate ImportError.
    try:
        from google.auth import compute_engine
        from google.auth.compute_engine import _metadata
    except ImportError:
        return None, None

    if request is None:
        request = google.auth.transport._http_client.Request()

    if _metadata.ping(request=request):
        # Get the project ID.
        try:
            project_id = _metadata.get_project_id(request=request)
        except exceptions.TransportError:
            project_id = None

        return compute_engine.Credentials(), project_id
    else:
        return None, None
941887
def from_credentials(credentials, loop: asyncio.AbstractEventLoop=asyncio.get_event_loop()):
        
        return API(username=credentials.username, password=credentials.password,
                   database=credentials.database, session_id=credentials.session_id,
                   server=credentials.server, loop=loop)
971019
def Credentials(self):
		

		return(clc.v2.API.Call('GET','servers/%s/%s/credentials' % (self.alias,self.name),session=self.session))
743773
def _from_dict(cls, _dict):
        """"""
        args = {}
        if 'credentials' in _dict:
            args['credentials'] = [
                Credentials._from_dict(x) for x in (_dict.get('credentials'))
            ]
        return cls(**args)
733610
def credentials(self):
        """"""
        if self.filename:
            db_filename = os.path.join(os.getcwd(), self.filename)
        else:
            db_filename = None

        return {
            "username": self.username,
            "password": self.password,
            "hostname": self.hostname,
            "port": self.port,
            "filename": db_filename,
            "dbname": self.dbname,
            "dbtype": self.dbtype,
            "schemas": self.schemas,
            "limit": self.limit,
            "keys_per_column": self.keys_per_column,
        }
761462
def check_credentials(self, username, password):
        
        return password is not None and self.credentials.get(username, None) == password
424029
def _get_build_env(env):
    '''
    
    '''
    env_override = ''
    if env is None:
        return env_override
    if not isinstance(env, dict):
        raise SaltInvocationError(
            '\'env\' must be a Python dictionary'
        )
    for key, value in env.items():
        env_override += '{0}={1}\n'.format(key, value)
        env_override += 'export {0}\n'.format(key)
    return env_override
214409
def get_env():
    ''' 
    '''
    if getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS'):
        # PyInstaller uses _MEIPASS and only works with jinja2.FileSystemLoader
        templates_path = join(sys._MEIPASS, 'bokeh', 'core', '_templates')
    else:
        # Non-frozen Python and cx_Freeze can use __file__ directly
        templates_path = join(dirname(__file__), '_templates')

    return Environment(loader=FileSystemLoader(templates_path))
1142010
def from_credentials(credentials):
        
        return API(username=credentials.username, password=credentials.password,
                   database=credentials.database, session_id=credentials.session_id,
                   server=credentials.server)
306124
def get_envs(self, log=True):
        """"""
        if log:
            logger.debug('')
#        return self._call_and_parse(['info', '--json'],
#                                    callback=lambda o, e: o['envs'])
        envs = os.listdir(os.sep.join([self.ROOT_PREFIX, 'envs']))
        envs = [os.sep.join([self.ROOT_PREFIX, 'envs', i]) for i in envs]

        valid_envs = [e for e in envs if os.path.isdir(e) and
                      self.environment_exists(prefix=e)]

        return valid_envs
610354
def get_user_password(env, param, force=False):
    
    username = utils.assemble_username(env, param)

    if not utils.confirm_credential_display(force):
        return

    # Retrieve the credential from the keychain
    password = password_get(username)

    if password:
        return (username, password)
    else:
        return False