API#

Here: server classes#

async herethere.here.start_server(config: ~herethere.here.config.ServerConfig, namespace: dict = None, server_factory: type[~herethere.here.server.SSHServerHere] = <class 'herethere.here.server.SSHServerHere'>) RunningServer[source]#

Start SSH server.

Parameters:
  • config – server configuration options

  • namespace – dictionary in which Python code commands will be executed

  • server_factory – optional protocol handler class

class herethere.here.ServerConfig(host: str, port: int, username: str, password: str, key_path: str, chroot: str)[source]#

Bases: ConnectionConfig

SSH server configuration.

property asdict: dict[str, Any]#

Dict represntation of the instance.

classmethod load(prefix: str = '', path: str = None) ConnectionConfig#

Load configuration from the environment, and file with configurations variables. If path is not specified, variables are loaded from a file named {prefix}.env in the current directory or any of its parents.

Parameters:
  • prefix – prefix for variables ({PREFIX}_HOST), and a configuration file name to search for: {prefix}.env

  • path – explicit configuration file location

classmethod load_from_dict(*, env: dict[str, str], prefix: str) ConnectionConfig#

Load config from dictionary.

save(path: str, prefix: str = '')#

Save config to the given location.

class herethere.here.server.RunningServer(server: AbstractServer, namespace, executor: ThreadPoolExecutor, connections: set[SSHServerConnection])[source]#

Wrapper for a running SSH server instance.

async stop(timeout: float = 1.0)[source]#

Stop SSH server.

class herethere.here.server.SSHServerHere(username: str, password: str, executor: ThreadPoolExecutor, connections: set[SSHServerConnection] | None = None)[source]#

Bases: SSHServer

SSH server protocol handler with username and password options.

There: client classes#

class herethere.there.Client[source]#

Client for remote interpreter.

async connect(config: ConnectionConfig)[source]#

Connect to remote.

async copy() Client[source]#

Return a copy of the configured connection.

async disconnect()[source]#

Disconnect from the remote.

async runcode(code: str, stdout: TextIO | None = None, stderr: TextIO | None = None) str[source]#

Execute python code on the remote side.

async runcode_background(code: str, stdout: TextIO | None = None, stderr: TextIO | None = None) str[source]#

Execute python code in a separate thread on the remote side.

sftp_progress_handler(*args, **kwargs)[source]#

SFTP uploading progress handler.

async shell(code: str, stdout: TextIO | None = None, stderr: TextIO | None = None) str[source]#

Execute shell command on the remote side.

async upload(localpaths: list[str], remotepath) str[source]#

Upload files and directories to remote via SFTP.

class herethere.everywhere.config.ConnectionConfig(host: str, port: int, username: str, password: str)[source]#

Remote connection configuration.

property asdict: dict[str, Any]#

Dict represntation of the instance.

classmethod load(prefix: str = '', path: str = None) ConnectionConfig[source]#

Load configuration from the environment, and file with configurations variables. If path is not specified, variables are loaded from a file named {prefix}.env in the current directory or any of its parents.

Parameters:
  • prefix – prefix for variables ({PREFIX}_HOST), and a configuration file name to search for: {prefix}.env

  • path – explicit configuration file location

classmethod load_from_dict(*, env: dict[str, str], prefix: str) ConnectionConfig[source]#

Load config from dictionary.

save(path: str, prefix: str = '')[source]#

Save config to the given location.

herethere.there.commands.there_code_shortcut(handler: Callable[[str], str]) Callable[[Context], None][source]#

Decorator to register %there subcommand to execute Python code.

Parameters:

handler – a function, that receives text from the Jupyter cell, and returns Python code to execute on the remote side