Determine if user exists in specified environment.
481629
def user_exists_p(login, connector):
    
    url = '/users/' + login + '/'
    _r = connector.get(url)
    return (_r.status_code == Constants.PULP_GET_OK)
1359060
def _users_from_environ(env_prefix=''):
    """"""
    auth_string = os.environ.get(env_prefix + 'WSGI_AUTH_CREDENTIALS')
    if not auth_string:
        return {}

    result = {}
    for credentials in auth_string.split('|'):
        username, password = credentials.split(':', 1)
        result[username] = password
    return result
1329003
def _maybe_init_user(self):
    """"""
    user_name = os.environ.get('USER', '') or os.environ.get('USERNAME', '')
    cursor = self._db.cursor()
    cursor.execute('SELECT user_id FROM Users WHERE user_name = ?',
                   (user_name,))
    row = cursor.fetchone()
    if row:
      return row[0]
    user_id = self._create_id()
    cursor.execute(
        """
        INSERT INTO USERS (user_id, user_name, inserted_time)
        VALUES (?, ?, ?)
        """,
        (user_id, user_name, time.time()))
    return user_id
1258432
def exists(device=''):
    '''
    
    '''
    if os.path.exists(device):
        dev = os.stat(device).st_mode

        if stat.S_ISBLK(dev):
            return True

    return False
590761
def user_exists(self, username):
        

        response = self._get(self.rest_url + "/user",
                             params={"username": username})

        if not response.ok:
            return None

        return True
68709
def executable_exists(executable):
    """"""
    for directory in os.getenv("PATH").split(":"):
        if os.path.exists(os.path.join(directory, executable)):
            return True
    return False
370353
def basic_set_of_users_exists_in_the_database(context):
    
    user_model = get_user_model()
    user_model.objects.create(
        username='administrator',
        is_staff=True
    )
    user_model.objects.create(
        username='allowed_user'
    )
    user_model.objects.create(
        username='unallowed_user'
    )
191963
def verify(ctx):
    """"""
    oks = run_configurations(
        skipper(verify_environments),
        read_sections,
    )
    ctx.exit(0
             if False not in oks
             else 1)
1167492
def uid_exists(uid):
    """"""
    try:
        pwd.getpwuid(uid)
        uid_exists = True
    except KeyError:
        uid_exists = False
    return uid_exists
889581
def find_user(session, username):
    """"""
    resp = _make_request(session, FIND_USER_URL, username)
    if not resp:
        raise VooblyError('user not found')
    try:
        return int(resp[0]['uid'])
    except ValueError:
        raise VooblyError('user not found')
1365427
def admin?
    is_admin = ( ENV['USER'] == 'root' )
    unless is_admin
      ext_admin = exec(:check_admin) do |op, results|
        if op == :reduce
          results.values.include?(true)
        else
          results ? true : false
        end
      end
    end
    is_admin || ext_admin ? true : false
  end
682257
def db_exists(name, user=None, password=None, host=None, port=None, authdb=None):
    '''
    
    '''
    dbs = db_list(user, password, host, port, authdb=authdb)

    if isinstance(dbs, six.string_types):
        return False

    return name in dbs
633383
def exists(self):
        
        try:
            self.stat()
        except OSError as e:
            if e.errno not in (ENOENT, ENOTDIR):
                raise
            return False
        return True
92709
def has_app(name, check_platform=True):
        """"""
        if check_platform:
            Environment._platform_is_windows()
        return which(str(name)) is not None
628201
def user_exists_in_group(user_name, group_name, region=None, key=None, keyid=None,
                         profile=None):
    '''
    
    '''
    # TODO this should probably use boto.iam.get_groups_for_user
    users = get_group_members(
        group_name=group_name, region=region, key=key, keyid=keyid,
        profile=profile
    )
    if users:
        for _user in users:
            if user_name == _user['user_name']:
                log.debug('IAM user %s is already in IAM group %s.', user_name, group_name)
                return True
    return False
911898
def getuser():
    """"""
    is_windows = platform.system() == "Windows"
    no_username_in_env = os.environ.get("USERNAME") is None
    return cross_platform_getuser(is_windows, no_username_in_env)
681262
def check_user(user):
    '''
    
    '''
    if salt.utils.platform.is_windows():
        return True
    if user == salt.utils.user.get_user():
        return True
    import pwd  # after confirming not running Windows
    try:
        pwuser = pwd.getpwnam(user)
        try:
            if hasattr(os, 'initgroups'):
                os.initgroups(user, pwuser.pw_gid)  # pylint: disable=minimum-python-version
            else:
                os.setgroups(salt.utils.user.get_gid_list(user, include_default=False))
            os.setgid(pwuser.pw_gid)
            os.setuid(pwuser.pw_uid)

            # We could just reset the whole environment but let's just override
            # the variables we can get from pwuser
            if 'HOME' in os.environ:
                os.environ['HOME'] = pwuser.pw_dir

            if 'SHELL' in os.environ:
                os.environ['SHELL'] = pwuser.pw_shell

            for envvar in ('USER', 'LOGNAME'):
                if envvar in os.environ:
                    os.environ[envvar] = pwuser.pw_name

        except OSError:
            msg = 'Salt configured to run as user "{0}" but unable to switch.'
            msg = msg.format(user)
            if is_console_configured():
                log.critical(msg)
            else:
                sys.stderr.write("CRITICAL: {0}\n".format(msg))
            return False
    except KeyError:
        msg = 'User not found: "{0}"'.format(user)
        if is_console_configured():
            log.critical(msg)
        else:
            sys.stderr.write("CRITICAL: {0}\n".format(msg))
        return False
    return True