API

Here: server classes

async herethere.here.start_server(config: herethere.here.config.ServerConfig, namespace: Optional[dict] = None, server_factory: Type[herethere.here.server.SSHServerHere] = <class 'herethere.here.server.SSHServerHere'>)herethere.here.server.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: herethere.everywhere.config.ConnectionConfig

SSH server configuration.

property asdict

Dict represntation of the instance.

classmethod load(prefix: str = '', path: Optional[str] = None)herethere.everywhere.config.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)herethere.everywhere.config.ConnectionConfig

Load config from dictionary.

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

Save config to the given location.

class herethere.here.server.RunningServer(server: asyncio.events.AbstractServer, namespace, executor: concurrent.futures.thread.ThreadPoolExecutor)[source]

Wrapper for a running SSH server instance.

async stop()[source]

Stop SSH server.

class herethere.here.server.SSHServerHere(username: str, password: str, executor: concurrent.futures.thread.ThreadPoolExecutor)[source]

Bases: asyncssh.server.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: herethere.everywhere.config.ConnectionConfig)[source]

Connect to remote.

async copy() → herethere.there.client.Client[source]

Return a copy of the configured connection.

async disconnect()[source]

Disconnect from the remote.

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

Execute python code on the remote side.

async runcode_background(code: str, stdout: Optional[TextIO] = None, stderr: Optional[TextIO] = 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: Optional[TextIO] = None, stderr: Optional[TextIO] = 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 represntation of the instance.

classmethod load(prefix: str = '', path: Optional[str] = None)herethere.everywhere.config.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)herethere.everywhere.config.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[[click.core.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