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)
        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.1.tar.gz (916.3 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.1-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for doover_scheduler-0.1.1.tar.gz
Algorithm Hash digest
SHA256 8db4e49952f2b7e0de5e5acca4ff2681b9daa1df1e822eeacd711560ce766b13
MD5 f207830365e92641a949aa851c7675d5
BLAKE2b-256 0e662bdce1375c3cab7a984b38964ef58948e117c415e805483df0a63b98ba51

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for doover_scheduler-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 38c52808bb96e1dea9537f79658774b3cf9efc3fe5c0e4a245aab35e8107c5a0
MD5 c9ffb856852ffa89512fd3b2eb009460
BLAKE2b-256 77fa307f0b38620d17784c20372cb6c80ca2f0c13c7f672a5da00a839287cd03

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