Squishy Applet

Todo

Flesh this out

class squishy.applets.SquishyApplet

Base class for all Squishy applets.

This class provides the public facing API for all Squishy applets, both internal and out-of-tree/third-party applet modules.

Squishy applets are made out of a combination of host-site Python logic and hardware-side gateware.

Variables:
  • name (str) – The name used to address this applet and display in the help documentation.

  • description (str) – A short description of this applet.

  • preview (bool) – If this applet is preview/pre-release.

  • version (float) – The version of the applet.

  • supported_platforms (tuple[tuple[int, int], ...]) – The platform revisions this applet supports.

abstract property name: str

The name of the applet.

abstract property description: str

Short description of the applet.

abstract property preview: bool

If this applet is a preview or not

abstract property version: float

Applet version

abstract property supported_platforms: tuple[tuple[int, int], ...]

The platforms this applet supports.

is_supported(platform: SquishyPlatform | Platform) bool

Check to see if the given platform is supported.

Parameters:

platform (squishy.gateware.SquishyPlatformType) – The platform to check against.

Returns:

True if the given platform is supported by this applet, otherwise False.

Return type:

bool

abstract register_args(parser: ArgumentParser) None

Register applet argument parsers.

Prior to initialize() and run() this method will be called to allow the applet to register any wanted command line options.

This is also used when displaying help.

Parameters:

parser (argparse.ArgumentParser) – The Squishy CLI argument parser group to register arguments into.

Raises:

NotImplementedError – The abstract method must be implemented by the applet.

abstract initialize(args: Namespace) AppletElaboratable | None

Initialize applet.

This is called prior to the gateware side of the applet being elaborated. It ensures that any initialization and configuration needed to be done can be done.

Parameters:

args (argsparse.Namespace) – The parsed arguments from the Squishy CLI

Returns:

An AppletElaboratable if initialization was successful otherwise None

Return type:

AppletElaboratable | None

Raises:

NotImplementedError – The abstract method must be implemented by the applet.

abstract run(args: Namespace, dev: SquishyDevice) int

Invoke the applet.

This method is run when the Squishy CLI has determined that this applet was to be ran.

This is for host-side applet logic only, such as USB communication, if the applet does not have any host-side logic, this may simple just return 0 as if it ran successfully.

Parameters:
Returns:

0 if run was successful, otherwise an error code.

Return type:

int

Raises:

NotImplementedError – The abstract method must be implemented by the applet.