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 hashes)

Uploaded Source

Built Distribution

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

Uploaded Python 2

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