Skip to main content

This Python script provides functionality to schedule and execute scripts based on cron expressions. It allows executing both bash and Python scripts and provides options to add script parameters and skip conditions.

Project description

Orchestration

The Orchestration library provides functionality to schedule and execute tasks based on cron expressions. It allows you to add skip conditions and dynamically generate script parameters. This library is designed to simplify the process of automating script execution.

Table of Contents

Installation

To use the Orchestration library, you need to have Python installed. You can then install the library using pip:

pip install orchestration

Usage

Creating an Orchestrator

To get started with the Orchestrator library, you need to create an instance of the Orchestrator class:

from orchestration import Orchestrator

orchestrator = Orchestrator()

Adding Tasks

You can add tasks to the orchestrator using the add_task method. The add_task method takes two arguments: cron_expression and script_type. The cron_expression specifies the schedule for the task using cron syntax, and the script_type specifies the type of script to execute (e.g., 'bash' or 'python').

task = orchestrator.add_task('0 * * * *', 'bash')

You can also specify an optional interval argument to set the interval in seconds between task executions (default is 1 second).

Adding Scripts

You can add scripts to a task using the add_script method. The add_script method takes the script_path argument, which specifies the path to the script file, and an optional script_parameters argument, which is a dictionary of parameters to pass to the script.

task.add_script('/path/to/script.sh', {'param1': 'value1', 'param2': 'value2'})

Adding Repeats

You can run the same script multiple times with different parameters using the add_repeat method. The add_repeat method takes the script_path argument, which specifies the path to the script file, and a script_parameters argument, which is a list of dictionaries of parameters to pass to the script.

task.add_repeat('/path/to/script.sh', [{'param1': 'value1', 'param2': 'value2'}, {'param1': 'value3', 'param2': 'value4'}])

Adding Skip Conditions

Skip conditions allow you to specify conditions under which a task should be skipped during execution. You can add skip conditions to a task using the add_skip method.

task.add_skip(some_skip_condition)

Executing Tasks

Once you have added tasks to the orchestrator, you can start executing them by calling the execute_tasks method. This method will continuously check if any tasks need to be executed based on their cron expressions and execute the corresponding scripts.

orchestrator.execute_tasks()

The script(s) will be executed using the specified script_type (e.g., 'bash' or 'python').

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

orchestration-1.1.3.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

orchestration-1.1.3-py2-none-any.whl (4.2 kB view details)

Uploaded Python 2

File details

Details for the file orchestration-1.1.3.tar.gz.

File metadata

  • Download URL: orchestration-1.1.3.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for orchestration-1.1.3.tar.gz
Algorithm Hash digest
SHA256 89ce26882db28702bd665a897165fcada28efb14ffb2ae8e6235de1bcf5db681
MD5 744e71e6c1549cb6188fe3e07c25864f
BLAKE2b-256 536340c5f89969d909fa77ba8f8db2be21c778c1d2d281e9981a41aafd2c894d

See more details on using hashes here.

File details

Details for the file orchestration-1.1.3-py2-none-any.whl.

File metadata

File hashes

Hashes for orchestration-1.1.3-py2-none-any.whl
Algorithm Hash digest
SHA256 8523fe6009026ae7f7ad5ad53451c232e748515a56918a5768664821dfa8c4d1
MD5 8704e1c1f4f4d80139a9bdab34314ac8
BLAKE2b-256 7dbad8c4d80217154eb9aeaf134fe0ed395f87a966c164e1c7ea1186324f5ad0

See more details on using hashes here.

Supported by

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