Get user by ``pk`` or ``username``. Raise error if it doesn't exist.
351949
def fetch_user(query):
    """"""
    user_filter = {'pk': query} if query.isdigit() else {'username': query}
    user_model = get_user_model()

    try:
        return user_model.objects.get(**user_filter)
    except user_model.DoesNotExist:
        raise exceptions.ParseError("Unknown user: {}".format(query))
1126359
def get_user_by_username(name)
      resp = request('getUserByUsername', username: name)['user']
      resp['user_id'].nil? ? nil : User.new(self, resp)
    end
168950
def get_user(self, user_id, **params):
        """"""
        response = self._get('v2', 'users', user_id, params=params)
        return self._make_api_object(response, User)
937156
def get_user_by_id(self, id):
        """"""
        return self.db_adapter.get_object(self.UserClass, id=id)
243545
def find_by_username(self, username):
        """"""
        data = (db.select(self.table).select('username', 'email', 'real_name',
                                             'password', 'bio', 'status', 'role', 'uid').
                condition('username', username).execute()
                )
        if data:
            return self.load(data[0], self.model)
190913
def fetchUser(self, username, rawResults = False) :
        """"""
        url = "%s/%s" % (self.URL, username)

        r = self.connection.session.get(url)
        if r.status_code == 200 :
            data = r.json()
            if rawResults :
                return data["result"]
            else :
                u = User(self, data)
                return u
        else :
            raise KeyError("Unable to get user: %s" % username)
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)
1243035
def _resolve_username(self, account, username):
        """"""
        if account is not None:
            warnings.warn(
                "Use keyword argument 'username' instead of 'account'",
                DeprecationWarning)
        return username or account or self.username
590761
def user_exists(self, username):
        

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

        if not response.ok:
            return None

        return True
1193716
def by_user_name(cls, username):
        """"""
        return DBSession.query(cls).filter_by(user_name=username).first()
879471
def get(self, user_id):
        """"""
        user = db.User.find_one(User.user_id == user_id)
        roles = db.Role.all()

        if not user:
            return self.make_response('Unable to find the user requested, might have been removed', HTTP.NOT_FOUND)

        return self.make_response({
            'user': user.to_json(),
            'roles': roles
        }, HTTP.OK)
1028012
def get_user(self, request):
        
        try:
            return User.objects.get(username=request.data.get('username'),
                                    is_active=True)
        except User.DoesNotExist:
            return None
516537
def user_exists(name, runas=None):
    '''
    
    '''
    if runas is None and not salt.utils.platform.is_windows():
        runas = salt.utils.user.get_user()
    return name in list_users(runas=runas)
481629
def user_exists_p(login, connector):
    
    url = '/users/' + login + '/'
    _r = connector.get(url)
    return (_r.status_code == Constants.PULP_GET_OK)
622025
def get_user(user=None):
    
    if user is None:
        # Return the current authenticated user
        user = getSecurityManager().getUser()
    elif isinstance(user, MemberData):
        # MemberData wrapped user -> get the user object
        user = user.getUser()
    elif isinstance(user, basestring):
        # User ID -> get the user
        user = get_member_by_login_name(get_portal(), user, False)
        if user:
            user = user.getUser()
    return user
325216
def find_user_by_username(self, username):
        """"""
        return self.db_adapter.ifind_first_object(self.UserClass, username=username)
567175
def get_user(self, user_id):
        
        try:
            return User.objects.get(id=user_id)
        except User.DoesNotExist:
            return None