efro.cloudshell

My nifty ssh/mosh/rsync mishmash.

 1# Released under the MIT License. See LICENSE for details.
 2#
 3"""My nifty ssh/mosh/rsync mishmash."""
 4
 5from __future__ import annotations
 6
 7from enum import Enum
 8from dataclasses import dataclass
 9
10from efro.dataclassio import ioprepped
11
12
13class LockType(Enum):
14    """Types of locks that can be acquired on a host."""
15
16    HOST = 'host'
17    WORKSPACE = 'workspace'
18    PYCHARM = 'pycharm'
19    CLION = 'clion'
20
21
22@ioprepped
23@dataclass
24class HostConfig:
25    """Config for a cloud machine to run commands on.
26
27    precommand, if set, will be run before the passed commands.
28    Note that it is not run in interactive mode (when no command is given).
29    """
30
31    address: str | None = None
32    user: str = 'ubuntu'
33    port: int = 22
34    mosh_port: int | None = None
35    mosh_port_2: int | None = None
36    mosh_server_path: str | None = None
37    mosh_shell: str = 'sh'
38    workspaces_root: str = '/home/${USER}/cloudshell_workspaces'
39    sync_perms: bool = True
40    precommand_noninteractive: str | None = None
41    precommand_interactive: str | None = None
42    managed: bool = False
43    region: str | None = None
44    idle_minutes: int = 5
45    can_sudo_reboot: bool = False
46    max_sessions: int = 4
47    reboot_wait_seconds: int = 20
48    reboot_attempts: int = 1
49
50    def resolved_workspaces_root(self) -> str:
51        """Returns workspaces_root with standard substitutions."""
52        return self.workspaces_root.replace('${USER}', self.user)
class LockType(enum.Enum):
14class LockType(Enum):
15    """Types of locks that can be acquired on a host."""
16
17    HOST = 'host'
18    WORKSPACE = 'workspace'
19    PYCHARM = 'pycharm'
20    CLION = 'clion'

Types of locks that can be acquired on a host.

HOST = <LockType.HOST: 'host'>
WORKSPACE = <LockType.WORKSPACE: 'workspace'>
PYCHARM = <LockType.PYCHARM: 'pycharm'>
CLION = <LockType.CLION: 'clion'>
Inherited Members
enum.Enum
name
value
@ioprepped
@dataclass
class HostConfig:
23@ioprepped
24@dataclass
25class HostConfig:
26    """Config for a cloud machine to run commands on.
27
28    precommand, if set, will be run before the passed commands.
29    Note that it is not run in interactive mode (when no command is given).
30    """
31
32    address: str | None = None
33    user: str = 'ubuntu'
34    port: int = 22
35    mosh_port: int | None = None
36    mosh_port_2: int | None = None
37    mosh_server_path: str | None = None
38    mosh_shell: str = 'sh'
39    workspaces_root: str = '/home/${USER}/cloudshell_workspaces'
40    sync_perms: bool = True
41    precommand_noninteractive: str | None = None
42    precommand_interactive: str | None = None
43    managed: bool = False
44    region: str | None = None
45    idle_minutes: int = 5
46    can_sudo_reboot: bool = False
47    max_sessions: int = 4
48    reboot_wait_seconds: int = 20
49    reboot_attempts: int = 1
50
51    def resolved_workspaces_root(self) -> str:
52        """Returns workspaces_root with standard substitutions."""
53        return self.workspaces_root.replace('${USER}', self.user)

Config for a cloud machine to run commands on.

precommand, if set, will be run before the passed commands. Note that it is not run in interactive mode (when no command is given).

HostConfig( address: str | None = None, user: str = 'ubuntu', port: int = 22, mosh_port: int | None = None, mosh_port_2: int | None = None, mosh_server_path: str | None = None, mosh_shell: str = 'sh', workspaces_root: str = '/home/${USER}/cloudshell_workspaces', sync_perms: bool = True, precommand_noninteractive: str | None = None, precommand_interactive: str | None = None, managed: bool = False, region: str | None = None, idle_minutes: int = 5, can_sudo_reboot: bool = False, max_sessions: int = 4, reboot_wait_seconds: int = 20, reboot_attempts: int = 1)
address: str | None = None
user: str = 'ubuntu'
port: int = 22
mosh_port: int | None = None
mosh_port_2: int | None = None
mosh_server_path: str | None = None
mosh_shell: str = 'sh'
workspaces_root: str = '/home/${USER}/cloudshell_workspaces'
sync_perms: bool = True
precommand_noninteractive: str | None = None
precommand_interactive: str | None = None
managed: bool = False
region: str | None = None
idle_minutes: int = 5
can_sudo_reboot: bool = False
max_sessions: int = 4
reboot_wait_seconds: int = 20
reboot_attempts: int = 1
def resolved_workspaces_root(self) -> str:
51    def resolved_workspaces_root(self) -> str:
52        """Returns workspaces_root with standard substitutions."""
53        return self.workspaces_root.replace('${USER}', self.user)

Returns workspaces_root with standard substitutions.