trading_agent.terminal.widgets.pending_files
¶
The files waiting to go with the next message, shown on a line above the message box.
Each file is uploaded as soon as it is added, as on the web page, and shows "uploading…", "ready", "attached, but its text cannot be read", or why it failed. Backspace in the empty message box removes the newest file.
Typical usage example:
tray = PendingFiles(gateway) tray.add('general', Path('chart.png')) ids = await tray.ready_ids()
PendingFile
dataclass
¶
One file added to the message being written.
Attributes:
| Name | Type | Description |
|---|---|---|
local_id |
int
|
A number for the file while it waits. |
path |
Path
|
The local file. |
status |
str
|
"uploading", "ready" or "failed". |
attachment |
dict[str, Any] | None
|
The gateway's attachment once uploaded, or None. |
error |
str | None
|
Why it failed, or None. |
PendingFiles
¶
Bases: Static
The tray of files; hidden while empty.
Creates the tray, empty.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gateway
|
GatewayClient
|
The gateway, to upload to. |
required |
Source code in src/trading_agent/terminal/widgets/pending_files.py
on_mount
¶
add
¶
Adds a file and starts uploading it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
desk_name
|
str
|
The desk the message goes to. |
required |
path
|
Path
|
The local file. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
Why the file cannot be attached, or None when it was added. |
Source code in src/trading_agent/terminal/widgets/pending_files.py
remove_newest
¶
Removes the newest file.
Returns:
| Type | Description |
|---|---|
bool
|
True when a file was removed. |
has_files
¶
Says whether any file waits.
Returns:
| Type | Description |
|---|---|
bool
|
True when the tray is not empty. |
ready_ids
async
¶
Waits for the uploads to finish.
Returns:
| Type | Description |
|---|---|
tuple[list[str], list[str]]
|
The ids of the uploaded files, and the problems of the files that failed. |