コード例 #1
0
def get_status_by_id(user_id, dl_id):
    """Get the status of the download."""
    gw = SystemGateway()
    try:
        download = gw.get_download_by_id(user_id, dl_id)
    except errors.DoesNotExist:
        return UNKNOWN
    return get_status_from_download(user_id, download)
コード例 #2
0
def get_status_by_id(user_id, dl_id):
    """Get the status of the download."""
    gw = SystemGateway()
    try:
        download = gw.get_download_by_id(user_id, dl_id)
    except errors.DoesNotExist:
        return UNKNOWN
    return get_status_from_download(user_id, download)
コード例 #3
0
def get_status(user_id, volume_id, path, download_url, dl_key):
    """Get the status of the download."""
    gw = SystemGateway()
    try:
        download = gw.get_download(
            user_id, volume_id, path, download_url, dl_key)
    except errors.DoesNotExist:
        return UNKNOWN
    return get_status_from_download(user_id, download)
コード例 #4
0
def download_update(user_id, download_id, status=None,
                    node_id=None, error_message=None):
    """Update a download directly.

    Typically this isn't used.
    """
    gw = SystemGateway()
    return gw.update_download(user_id, download_id, status=status,
                              node_id=node_id, error_message=error_message)
コード例 #5
0
def download_update(user_id, download_id, status=None,
                    node_id=None, error_message=None):
    """Update a download directly.

    Typically this isn't used.
    """
    gw = SystemGateway()
    return gw.update_download(user_id, download_id, status=status,
                              node_id=node_id, error_message=error_message)
コード例 #6
0
def get_status(user_id, volume_id, path, download_url, dl_key):
    """Get the status of the download."""
    gw = SystemGateway()
    try:
        download = gw.get_download(
            user_id, volume_id, path, download_url, dl_key)
    except errors.DoesNotExist:
        return UNKNOWN
    return get_status_from_download(user_id, download)
コード例 #7
0
def get_or_make_download(user_id, volume_id, path, download_url, dl_key):
    """Get or make a download if it doesn't already exist."""
    gw = SystemGateway()
    try:
        download = gw.get_download(
            user_id, volume_id, path, download_url, dl_key)
    except errors.DoesNotExist:
        download = gw.make_download(
            user_id, volume_id, path, download_url, dl_key)
    return download
コード例 #8
0
def get_or_make_download(user_id, volume_id, path, download_url, dl_key):
    """Get or make a download if it doesn't already exist."""
    gw = SystemGateway()
    try:
        download = gw.get_download(
            user_id, volume_id, path, download_url, dl_key)
    except errors.DoesNotExist:
        download = gw.make_download(
            user_id, volume_id, path, download_url, dl_key)
    return download
コード例 #9
0
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
コード例 #10
0
    def test_txlogs_when_user_signs_up(self):
        """When user signs up, txlogs for new user and root UDF are created."""
        user = SystemGateway().create_or_update_user(username='******',
                                                     max_storage_bytes=1234)

        udf_txlog = TransactionLog.objects.get(
            op_type=TransactionLog.OP_UDF_CREATED)
        self.assertTxLogDetailsMatchesUserVolumeDetails(
            udf_txlog, user.root_volume, TransactionLog.OP_UDF_CREATED)

        user_txlog = TransactionLog.objects.get(
            op_type=TransactionLog.OP_USER_CREATED)
        self.assertTxLogDetailsMatchesUserDetails(user, user_txlog)
コード例 #11
0
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
コード例 #12
0
def make_download(user_id, udf_id, file_path, download_url, download_key=None):
    """Create a new download object."""
    gw = SystemGateway()
    return gw.make_download(
        user_id, udf_id, file_path, download_url, download_key)
コード例 #13
0
def download_complete(user_id, download_id, hash, crc32, size,
                      deflated_size, mimetype, storage_key):
    """Complete the download."""
    gw = SystemGateway()
    return gw.download_complete(user_id, download_id, hash, crc32, size,
                                deflated_size, mimetype, storage_key)
コード例 #14
0
def get_download(user_id, udf_id, file_path, download_url, download_key=None):
    """Get a download by its UDF, file path and download URL and key."""
    gw = SystemGateway()
    return gw.get_download(
        user_id, udf_id, file_path, download_url, download_key)
コード例 #15
0
def download_start(user_id, download_id):
    """Start the download."""
    SystemGateway().update_download(user_id, download_id,
                                    status=Download.STATUS_DOWNLOADING)
コード例 #16
0
def download_error(user_id, download_id, message):
    """Mark the download as in error."""
    return SystemGateway().update_download(
        user_id, download_id,
        status=Download.STATUS_ERROR, error_message=message)
コード例 #17
0
def get_download_by_id(user_id, download_id):
    """Get a download by its ID."""
    gw = SystemGateway()
    return gw.get_download_by_id(user_id, download_id)
コード例 #18
0
def get_failed_downloads(start_date, end_date):
    """Get the failed downloads between start_date and end_date."""
    gw = SystemGateway()
    return gw.get_failed_downloads(start_date, end_date)
コード例 #19
0
def get_download(user_id, udf_id, file_path, download_url, download_key=None):
    """Get a download by its UDF, file path and download URL and key."""
    gw = SystemGateway()
    return gw.get_download(
        user_id, udf_id, file_path, download_url, download_key)
コード例 #20
0
def make_download(user_id, udf_id, file_path, download_url, download_key=None):
    """Create a new download object."""
    gw = SystemGateway()
    return gw.make_download(
        user_id, udf_id, file_path, download_url, download_key)
コード例 #21
0
def get_download_by_id(user_id, download_id):
    """Get a download by its ID."""
    gw = SystemGateway()
    return gw.get_download_by_id(user_id, download_id)
コード例 #22
0
def get_failed_downloads(start_date, end_date):
    """Get the failed downloads between start_date and end_date."""
    gw = SystemGateway()
    return gw.get_failed_downloads(start_date, end_date)
コード例 #23
0
def download_complete(user_id, download_id, hash, crc32, size,
                      deflated_size, mimetype, storage_key):
    """Complete the download."""
    gw = SystemGateway()
    return gw.download_complete(user_id, download_id, hash, crc32, size,
                                deflated_size, mimetype, storage_key)