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.
-
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 laterSevereCheckError– Check executions fails severely
-
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 inappropriateReturn type: autosuspend.checks.Check- name (
-
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.
-
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 madeReturn type: typing.Optional[datetime.datetime]Returns: a datetime describing when the system needs to be running again or
Noneif no wakeup is required. Use timezone aware datetimes.Raises: TemporaryCheckError– Check execution currently fails but might recover laterSevereCheckError– Check executions fails severely
-
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 inappropriateReturn type: autosuspend.checks.Check- name (
-
options()¶ Return the configured options as a mapping.
This is used for debugging purposes only.
Return type: typing.Mapping[str,typing.Any]
-