client.py

tcprocd client.

class tcprocd.client.SocketShell(client)[source]

Bases: object

A class to connect to a process’s thread.

Adds a line buffer for the socket and passes received messages to on_receive. Messages by the user are passed to on_stdin.

Parameters:clienttcprocd.client.Client - The client to use for the connection.
on_stdin_ready()[source]

Called when some input is ready.

on_socket_ready()[source]

Called when receiving some process output.

run()[source]

Start waiting for input/output.

exception tcprocd.client.AuthenticationError[source]

Bases: Exception

Exception raised when authentication fails.

exception tcprocd.client.ServerError[source]

Bases: Exception

Exception raised when the server answers with an error.

class tcprocd.client.Client(server_address)[source]

Bases: object

A class to connect to a tcprocd server.

Parameters:server_address – tuple of host and port or the path to the socket file
connect(username=None, password=None, username_callback=None, password_callback=None)[source]

Connect to the server.

close()[source]

Close the connection.

list()[source]

List servers.

cat(name, start=0)[source]

Get output of given process.

Parameters:
  • namestr - Name of the process.
  • startint - Start at this line. (Default: 0)
Returns:

str - Multi-line output of the process.

start(name, command, path='')[source]

Create a new process with the given name and command.

Parameters:
  • namestr - Name of the process.
  • commandstr - The command to run the process.
  • pathstr - The (remote) path to execute the command in. (Default: None)
Returns:

str - Status message

kill(name)[source]

Kill the given process.

Parameters:namestr - Name of the process.
Returns:str - Status message
command(name, command)[source]

Write the given command to the given process’s stdin.

Parameters:
  • namestr - Name of the process.
  • commandstr - The command to send to the process.
Returns:

str - Status message

attach(name)[source]

Attach to the given process’s shell.

Parameters:namestr - Name of the process.
Returns:str - Status message