swergio_toolbox package

swergio_toolbox.objects module

class swergio_toolbox.objects.MutableBool(value=False)[source]

Bases: MutableObject

A class representing a mutable boolean value.

Parameters:

value (bool) – The initial value of the boolean.

class swergio_toolbox.objects.MutableNumber(value=0)[source]

Bases: MutableObject

A class representing a mutable number value.

Parameters:

value (int or float) – The initial value of the number.

class swergio_toolbox.objects.MutableObject(value=None)[source]

Bases: object

A class representing a mutable object with a value.

Parameters:

value (Any) – The value of the object.

Variables:

value (Any) – The value of the object.

set(value)[source]

Set the value of the object.

Parameters:

value (Any) – The new value of the object.

swergio_toolbox.swarm_control module

class swergio_toolbox.swarm_control.Component(filepath, envpath=None, delay=None, terminal_cmd=None, python_cmd='python')[source]

Bases: object

A class representing a component that can be started and stopped.

Parameters:
  • filepath (str) – The file path of the component.

  • envpath (str) – Path to environment used to execute python or julia code.

  • delay (int or float) – The delay in seconds before starting the component.

  • terminal_cmd (str) – Command used to start the component in a terminal. When None no terminal is used.

  • python_cmd (str) – Command to run python file. Default “python”.

Variables:
  • filepath (str) – The file path of the component.

  • envpath (str) – Path to environment used to execute python or julia code.

  • delay (int or float) – The delay in seconds before starting the component.

  • process (subprocess.Popen) – The subprocess object representing the running component.

  • terminal_cmd (str) – Command used to start the component in a terminal. When None no terminal is used.

  • python_cmd (str) – Command to run python file. Default “python”.

start()[source]

Start the component.

Returns:

The delay in seconds before starting the component, or None if the file extension is not recognized.

Return type:

int or float or None

stop()[source]

Stop the component.

class swergio_toolbox.swarm_control.Swarm(config_file=None)[source]

Bases: object

A class representing a swarm of components that can be started and stopped as a group.

Parameters:

config_file (str) – The file path of the configuration file.

Variables:
  • config (dict) – The configuration for the swarm.

  • components (dict) – The components in the swarm.

add(name, filepath, envpath=None, delay=None, terminal_cmd=None, python_cmd='python')[source]

Add a new component to the swarm.

Parameters:
  • name (str) – The name of the new component.

  • filepath (str) – The file path of the new component.

  • envpath (str) – Path to environment used to execute python or julia code.

  • delay (int or float) – The delay in seconds before starting the new component.

  • terminal_cmd (str) – Command used to start the component in a terminal. When None no terminal is used. If terminal_cmd is “”, the terminal_cmd of the swarm will be used.

  • python_cmd (str) – Command to run python file. Default “python”. If python_cmd is “”, the python_cmd of the swarm will be used.

Returns:

None

start(components=None)[source]

Start the specified components in the swarm.

Parameters:

components (list of str or str or None) – The names of the components to start. If not provided, all components will be started.

Returns:

None

stop(components=None)[source]

Stop the specified components in the swarm.

Parameters:

components (list of str or str or None) – The names of the components to stop. If not provided, all components will be stopped.

Returns:

None