Skip to main content

Task automation library

Project description

TasKKontrol Logo

TasKKontrol is a package for automating tasks.

Basic structure:

  • Trigger objects are used to keep track of when tasks need to execute.
  • Task objects link together a Trigger object and a function that represents the task.
  • A singular Kontroller object is used to manage all tasks.

Triggers

This version of this package implements 3 types of triggers all inheriting the Trigger object.

ConditionTrigger Object:

Defined using a function, which when returns True will activate the trigger. Example usage:

value = 10

def is_large ():
      global value
      return True if value > 5 else False

my_trigger = ConditionTrigger(is_large)

CompletionTrigger Object:

Defined using another Task object, trigger activates when the task is finished executing. Example usage:

def true ():
      return True

def do_work ():
      print("Working")

first_task = Task(ConditionTrigger(true), do_work)
second_task = Task(CompletionTrigger(first_task), do_work)

TimerTrigger Object:

Defined using a gmtime object, trigger will activate at the time of the object. Example usage:

from time import time, gmtime

start_time = time()

delay_trigger = TimerTrigger(gmtime(start_time + 10)) # 10 second delay

Tasks

Task Object:

Constructor takes a Trigger object and a target function which will be executed when the trigger activates. Example usage:

value = 10

def is_large ():
      global value
      return True if value > 5 else False

def do_work ():
      print("Working")

my_task = Task(ConditionTrigger(is_large), do_work)

Kontroller

Kontroller Object:

All tasks need to be added to a Kontroller instance using the addTask() member function. To begin the execution of tasks the Kontroller instance needs to be started either with the start() or launch() member functions. Using the start() function is recomended as it initiates the Kontroller on a seperate thread allowing for concurrent execution. Example usage:

from TasKKontrol.Task import Task
from TasKKontrol.Triggers import ConditionTrigger, CompletionTrigger
from TasKKontrol.Kontroller import Kontroller

def true ():
      return True

def print1 ():
      print("1")

def print2 ():
      print("2")

def print3 ():
      print("3")

# instantiate Kontroller
kontroller = Kontroller()

# create tasks
task1 = Task(ConditionTrigger(true), print1)
task2 = Task(CompletionTrigger(task1), print2)
task3 = Task(CompletionTrigger(task2), print3)

# add tasks
kontroller.addTask(task1)
kontroller.addTask(task2)
kontroller.addTask(task3)

# start the kontroller
kontroller.start()

# start() function is nonblocking
print("Work in parallel with kontroller")

# wait for kontroller to finish
kontroller.wait_finish()

Created and maintained by Artyom Yesayan

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

taskkontrol-0.1.0a0.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

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

TasKKontrol-0.1.0a0-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file taskkontrol-0.1.0a0.tar.gz.

File metadata

  • Download URL: taskkontrol-0.1.0a0.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for taskkontrol-0.1.0a0.tar.gz
Algorithm Hash digest
SHA256 297be782ad56b0c40563a2c856ef61e9f46b3bddb0ca20123ddd2b46ab986414
MD5 e59e8e8e23a952a43acb148f4210e71d
BLAKE2b-256 4134193f26d9836581abff4e11b7f0754f63b315f1450540c20b0260fce57937

See more details on using hashes here.

File details

Details for the file TasKKontrol-0.1.0a0-py3-none-any.whl.

File metadata

  • Download URL: TasKKontrol-0.1.0a0-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for TasKKontrol-0.1.0a0-py3-none-any.whl
Algorithm Hash digest
SHA256 f590d2e143300d3cdb42a8c895ebd01e3ff84e3f73b3af59afc254f6a3e76164
MD5 fd2c77bf9c088ff59da4b8e7493d6bcb
BLAKE2b-256 463c7e9136a5c6d3a7fbc63ea86959e914789e54e72913e094078aa5b147e479

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