parted.timer module

Timer interface to “PedTimer” in parted

author:

Adolfo Gómez, dkmaster at dkmon dot com

class parted.timer.Timer(timer: cffi.FFI.CData | None = None)[source]

Bases: object

Timer interface to “PedTimer” in parted

property frac: float

Fraction of the timer elapsed

static new(callback: Callable[[Timer], None] | None = None) Timer[source]

Creates a new timer

Parameters:

callback (Optional[Callable[['Timer'], None]], optional) – Callback to invoke when the timer is triggered. Defaults to None.

Returns:

New timer

Return type:

Timer

Note

This is a wrapper for ped_timer_new, that returns a python Timer object

static new_nested(parent: Timer, nest_frac: float = 0, callback: Callable[[Timer], None] | None = None) Timer[source]

Creates a new nested timer

Parameters:
  • parent (Timer) – Parent timer

  • nest_frac (float, optional) – Fraction of the parent timer to nest. Defaults to 0.

  • callback (Optional[Callable[['Timer'], None]], optional) – Callback to invoke when the timer is triggered. Defaults to None.

Returns:

New timer

Return type:

Timer

property now: int

Current time of the timer

property obj: cffi.FFI.CData

Wrapped PedTimer* object

property predicted_end: int

Predicted end time of the timer

process_event()[source]

Processes the timer event

Note

This method is invoked by the timer callback when the timer is triggered. By default, it just calls the callback, if any. You can override this method to do something else, but maybe easier to just set a callback

reset() None[source]

Resets the timer

property start: int

Start time of the timer

property state_name: str | None

Returns the name of the current state of the timer

touch() None[source]

Updates the timer

Note

This is a wrapper for ped_timer_touch

update(frac: float) None[source]

Updates the timer with a fraction

Parameters:

frac (float) – Fraction to update the timer with

Note

This is a wrapper for ped_timer_update

parted.timer.timer_handler(timer: cffi.FFI.CData, context: cffi.FFI.CData) None[source]

Timer handler, called by parted when timer is triggered

Warning

This is the timer callback, it’s called by parted. Not directly by the user.