Python API documentation

In case custom checks are required, the following classes have to be subclassed.

class autosuspend.checks.Activity(name=None)

Base class for activity checks.

Subclasses must call this class’ __init__ method.

abstract check()

Determine if system activity exists that prevents suspending.

Return type

typing.Optional[str]

Returns

A string describing which condition currently prevents sleep, else None.

Raises
  • TemporaryCheckError – Check execution currently fails but might recover later

  • SevereCheckError – Check executions fails severely

abstract classmethod create(name, config)

Create a new check instance from the provided configuration.

Parameters
  • name (str) – user-defined name for the check

  • config (configparser.SectionProxy) – config parser section with the configuration for this check

Raises

ConfigurationError – Configuration for this check is inappropriate

Return type

~CheckType

options()

Return the configured options as a mapping.

This is used for debugging purposes only.

Return type

typing.Mapping[str, typing.Any]

class autosuspend.checks.Wakeup(name=None)

Represents a check for potential wake up points.

abstract check(timestamp)

Indicate if a wakeup has to be scheduled for this check.

Parameters

timestamp (datetime.datetime) – the time at which the call to the wakeup check is made

Return type

typing.Optional[datetime.datetime]

Returns

a datetime describing when the system needs to be running again or None if no wakeup is required. Use timezone aware datetimes.

Raises
  • TemporaryCheckError – Check execution currently fails but might recover later

  • SevereCheckError – Check executions fails severely

abstract classmethod create(name, config)

Create a new check instance from the provided configuration.

Parameters
  • name (str) – user-defined name for the check

  • config (configparser.SectionProxy) – config parser section with the configuration for this check

Raises

ConfigurationError – Configuration for this check is inappropriate

Return type

~CheckType

options()

Return the configured options as a mapping.

This is used for debugging purposes only.

Return type

typing.Mapping[str, typing.Any]