Skip to main content

Python package for managing Doover scheduled tasks.

Project description

Doover Scheduler

Easily manage schedules within your application using the Doover Scheduler.

This library provides a simple way to check the next scheduled time for a task and receive callbacks when a schedule window is started or ended.

Installation

The library is published to PyPI, so you can install it using uv or pip:

uv add doover-scheduler
# or
pip install doover-scheduler

You can install the latest development version directly from GitHub:

uv add git+https://github.com/spaneng/doover-scheduler.git
# or
pip install git+https://github.com/spaneng/doover-scheduler.git

Usage

This first example shows how to use the callbacks to get notified when a schedule starts or ends.

import doover_scheduler

from pydoover.docker import Application

class MyApp(Application):
    async def setup(self):
        self.scheduler = doover_scheduler.ScheduleController(self.device_agent)
        self.scheduler.register(self.on_schedule_start, self.on_schedule_end, self.on_schedule_update)
        await self.scheduler.setup()

        # add a UI component to the application for the scheduler
        self.ui_manager.add_children(doover_scheduler.ScheduleComponent())

    async def main_loop(self):
        await self.scheduler.main_loop()

    @doover_scheduler.on_start
    async def on_schedule_start(self, timeslot):
        print(f"Schedule started: {timeslot}")

    @doover_scheduler.on_end
    async def on_schedule_end(self, timeslot):
        print(f"Schedule finished: {timeslot}")
        
    @doover_scheduler.on_update
    async def on_schedule_update(self, new_schedule):
        print(f"Someone updated the schedule on the website: {new_schedule}")

The second example shows how to check the next scheduled time for a task.

import time

import doover_scheduler

from pydoover.docker import Application

class MyApp(Application):
    async def setup(self):
        self.scheduler = doover_scheduler.ScheduleController(self.device_agent)
        self.scheduler.register(self.on_schedule_start, self.on_schedule_end, self.on_schedule_update)
        await self.scheduler.setup()
        
        # add a UI component to the application for the scheduler
        self.ui_manager.add_children(doover_scheduler.ScheduleComponent())

    async def main_loop(self):
        await self.scheduler.main_loop()
        
        current_timeslot = self.scheduler.current_timeslot
        if current_timeslot:
            print(f"The current timeslot will finish in {int(current_timeslot.end_time - time.time())} seconds.")

        next_timeslot = self.scheduler.next_timeslot
        if next_timeslot:
            print(f"The next scheduled timeslot will start in {int(next_timeslot - time.time())} seconds.")

Contributing

For more information, please reach out to the maintainers at hello@doover.com

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

doover_scheduler-0.1.0.tar.gz (914.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

doover_scheduler-0.1.0-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file doover_scheduler-0.1.0.tar.gz.

File metadata

  • Download URL: doover_scheduler-0.1.0.tar.gz
  • Upload date:
  • Size: 914.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.7.19

File hashes

Hashes for doover_scheduler-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b72a0c06db9b3afbfb9cb9705a72c44855b08d6e3627043306c516588f11f706
MD5 ecdc4764be5c194101d8fd06abaf8937
BLAKE2b-256 f7f5ad259191890cf55b8cf57a7bf6f5082ee2725d40288ed6f9775edc5f596d

See more details on using hashes here.

File details

Details for the file doover_scheduler-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for doover_scheduler-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6b3cdadc32f058d2ed4b98e4773045d31f79af355fb53f951478ffe7200d4bfb
MD5 24e72bb06751f1082e94c56416d6b3c3
BLAKE2b-256 57b9733ed32d8f834fb18a2439fe6d4e0c3071956e01caa14e02edfa367a21ba

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page