sync changes with master

This commit is contained in:
Ayush Saini 2022-06-30 00:31:52 +05:30
parent 03034e4aa0
commit de0199ad50
178 changed files with 2191 additions and 1481 deletions

View file

@ -3,18 +3,34 @@
"""Functionality related to the bacloud tool."""
from __future__ import annotations
from dataclasses import dataclass
from typing import TYPE_CHECKING, Optional
from efro.dataclassio import ioprepped
from dataclasses import dataclass
from typing import TYPE_CHECKING, Annotated
from efro.dataclassio import ioprepped, IOAttrs
if TYPE_CHECKING:
pass
# Version is sent to the master-server with all commands. Can be incremented
# if we need to change behavior server-side to go along with client changes.
BACLOUD_VERSION = 6
@ioprepped
@dataclass
class Response:
class RequestData:
"""Request sent to bacloud server."""
command: Annotated[str, IOAttrs('c')]
token: Annotated[str | None, IOAttrs('t')]
payload: Annotated[dict, IOAttrs('p')]
tzoffset: Annotated[float, IOAttrs('z')]
isatty: Annotated[bool, IOAttrs('y')]
@ioprepped
@dataclass
class ResponseData:
# noinspection PyUnresolvedReferences
"""Response sent from the bacloud server to the client.
@ -35,10 +51,10 @@ class Response:
uploads_inline: If present, a list of pathnames that should be base64
gzipped and uploaded to an 'uploads_inline' dict in end_command args.
This should be limited to relatively small files.
deletes: If present, file paths that should be deleted on the client.
downloads_inline: If present, pathnames mapped to base64 gzipped data to
be written to the client. This should only be used for relatively
small files as they are all included inline as part of the response.
deletes: If present, file paths that should be deleted on the client.
dir_prune_empty: If present, all empty dirs under this one should be
removed.
open_url: If present, url to display to the user.
@ -52,20 +68,29 @@ class Response:
end_command: If present, this command is run with these args at the end
of response processing.
"""
message: Optional[str] = None
message_end: str = '\n'
error: Optional[str] = None
delay_seconds: float = 0.0
login: Optional[str] = None
logout: bool = False
dir_manifest: Optional[str] = None
uploads: Optional[tuple[list[str], str, dict]] = None
uploads_inline: Optional[list[str]] = None
downloads_inline: Optional[dict[str, str]] = None
deletes: Optional[list[str]] = None
dir_prune_empty: Optional[str] = None
open_url: Optional[str] = None
input_prompt: Optional[tuple[str, bool]] = None
end_message: Optional[str] = None
end_message_end: str = '\n'
end_command: Optional[tuple[str, dict]] = None
message: Annotated[str | None, IOAttrs('m', store_default=False)] = None
message_end: Annotated[str, IOAttrs('m_end', store_default=False)] = '\n'
error: Annotated[str | None, IOAttrs('e', store_default=False)] = None
delay_seconds: Annotated[float, IOAttrs('d', store_default=False)] = 0.0
login: Annotated[str | None, IOAttrs('l', store_default=False)] = None
logout: Annotated[bool, IOAttrs('lo', store_default=False)] = False
dir_manifest: Annotated[str | None,
IOAttrs('man', store_default=False)] = None
uploads: Annotated[tuple[list[str], str, dict] | None,
IOAttrs('u', store_default=False)] = None
uploads_inline: Annotated[list[str] | None,
IOAttrs('uinl', store_default=False)] = None
deletes: Annotated[list[str] | None,
IOAttrs('dlt', store_default=False)] = None
downloads_inline: Annotated[dict[str, str] | None,
IOAttrs('dinl', store_default=False)] = None
dir_prune_empty: Annotated[str | None,
IOAttrs('dpe', store_default=False)] = None
open_url: Annotated[str | None, IOAttrs('url', store_default=False)] = None
input_prompt: Annotated[tuple[str, bool] | None,
IOAttrs('inp', store_default=False)] = None
end_message: Annotated[str | None,
IOAttrs('em', store_default=False)] = None
end_message_end: Annotated[str, IOAttrs('eme', store_default=False)] = '\n'
end_command: Annotated[tuple[str, dict] | None,
IOAttrs('ec', store_default=False)] = None