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)
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)
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)
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
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 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)
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)
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)
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)
def download_start(user_id, download_id): """Start the download.""" SystemGateway().update_download(user_id, download_id, status=Download.STATUS_DOWNLOADING)
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)
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)
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)