def get_status_from_download(user_id, download):
    """Gets the status from a download object."""
    gw = SystemGateway()
    if download.status == Download.STATUS_COMPLETE:
        # check if the file is actually present
        gw.get_user(user_id)
        try:
            gw.get_node(download.node_id)
        except errors.DoesNotExist:
            return DOWNLOADED_NOT_PRESENT
    return download.status
def get_status_from_download(user_id, download):
    """Gets the status from a download object."""
    gw = SystemGateway()
    if download.status == model.DOWNLOAD_STATUS_COMPLETE:
        # check if the file is actually present
        user = gw.get_user(user_id)
        try:
            gw.get_node(download.node_id, user.shard_id)
        except errors.DoesNotExist:
            return DOWNLOADED_NOT_PRESENT
    return download.status
Exemplo n.º 3
0
def get_storage_user(user_id=None, username=None, session_id=None, active_only=True, readonly=False):
    """Get a storage user.

    readonly kwarg is just to not raise LockedUserError in case the user is
    locked.
    """
    gw = SystemGateway()
    user = gw.get_user(user_id=user_id, username=username, session_id=session_id, ignore_lock=readonly)
    if active_only and (user is None or not user.is_active):
        raise errors.DoesNotExist("User does not exist.")
    return user
Exemplo n.º 4
0
def get_storage_user(user_id=None, username=None, session_id=None,
                     active_only=True, readonly=False):
    """Get a storage user.

    readonly kwarg is just to not raise LockedUserError in case the user is
    locked.
    """
    gw = SystemGateway()
    user = gw.get_user(user_id=user_id, username=username,
                       session_id=session_id, ignore_lock=readonly)
    if active_only and (user is None or not user.is_active):
        raise errors.DoesNotExist("User does not exist.")
    return user