Progress Callbacks
Swibots have a number of built-in functions that can be used in the code of your Swibot. These functions are available in the swibot module.
DownloadProgressCallback
A callback function that is called when the download progress changes.
Signature
DownloadProgressCallback = Callable[[DownloadProgress], Coroutine[Any, Any, None]]
Parameters
progress(DownloadProgress): The download progress
DownloadProgress
The download progress.
Properties
downloaded(int): The number of bytes that have been downloadedtotal(int): The total number of bytes to downloadurl(str): The URL of the file being downloadedclient(IOClient): The client that is downloading the filefile_name(str): The file name of the file being downloadedstared(bool): Whether the download has started
UploadProgressCallback
A callback function that is called when the upload progress changes.
Signature
UploadProgressCallback = Callable[[UploadProgress], Coroutine[Any, Any, None]]
Parameters
progress(UploadProgress): The upload progress
UploadProgress
The upload progress.
Properties
current(int): The current chunk size (in bytes) being uploadedreaded(int): The number of bytes that have been uploadedurl(str): The URL of the file being uploadedclient(IOClient): The client that is uploading the filefile_name(str): The file name of the file being uploadedstarted(bool): Whether the upload has startedcallback(UploadProgressCallback): The callback function that is called when the upload progress changescallback_args(tuple): Additional arguments to pass to thecallbackcallback function
IOClient
The client that is used to download files. This is a class with just one metod cancel(), which can be used to cancel the download / upload.
It is used as a property of the DownloadProgress and UploadProgress objects.