Skip to main content

Cronably allows you run python scripts with configured repetitions easily

Project description

CRONABLY

Introduction

Cronably allows you run python scripts with configured repetitions easily. If want to use it from here you can take a look on install locally

Let me show you some features

About How it Running

Cronably can run just configuring the anotation like this:

from cronably import Cronably

@Cronably(name="HOLA_MUNDO")
def my_process():
    print "Hola Mundo"

Or using an external file, it should be named "cronably.txt" , it should be in the same path as the process:

from cronably.implementation import Cronably


@Cronably(ext_config=True)
def my_process_from_file():
    print "Hola Mundo"


if __name__ == '__main__':
    my_process_from_file()

And file should contains this:

name=HOLA_MUNDO

If you want to run from file, is mandatory to add allways the param ext_config. If you add that all parameters will be taken from file.If you add here and also into the file, it will be overwritten by file , in the other hand, if it doesn't exists in the file , will be used the configurations ones.

For this simple step you are telling to cronably that the method should run once. It's beacuse the default parameter loop, by default is 1. The field "name" is mandatory.

About Loops

You can tell to cronably the times you want to repeat, ( like a loop), with nothing, it will run only once If you put :

@Cronably(name="HOLA_MUNDO", loops = 10)
def my_process():
    print "Hola Mundo"

It will run 10 times

If you put :

@Cronably(name="HOLA_MUNDO", loops = -1)
def my_process():
    print "Hola Mundo"

It will not stop running, until you kill the process

Loops and repetitions

Loops live together with repetitions, it means you can repeat the process every lapse of time, but if you configure an amount of times to do it, it will stop once you accomplish this amount of times.

About Repetitions

Concrete elapse of times

Within the code:

@Cronably(name="HOLA_MUNDO", loops=10, repetition_frame= VALUE, repetition_period=15)
def my_process():
    print "Hola Mundo"

repetition_frame can be:

  • HOURS
  • MINUTES
  • SECONDS
  • DAYS

it will run 10 times the process every 15 MINUTES, from the moment you start the script

Within the file:

name=HOLA_MUNDO
loops=10
repetition.frame=HOURS
repetition.period=2

it will run 10 times the process every 2 HOURS

The repetitions will start from the moment you run the script.

Every Day, several times in specific hours

You should put as frame the value: DAILY

Within the code:

@Cronably( 
    name="HOLA_MUNDO", 
    loops=10, 
    repetition_frame= DAILY, 
    repetition_period='10:00,14:00,20:00' )
def my_process():
    print "Hola Mundo"

it will run 10 times the process every Day at 10:00, 14:00 and 20:00. Attention:

  • It must be ordered from minus to Minor
  • I'm using 0:00 to 23:59 style time.

Within the file:

name=HOLA_MUNDO
loops=10
repetition.frame=DAILY
repetition.period=10:00,14:00,20:00

Specific Days

You should put as frame the value: WEEKLY

Within the code:

@Cronably(name="HOLA_MUNDO", loops=10, repetition_frame= WEEKLY, repetition_period_day='Monday',repetition_period_time='10:00' )
def my_process():
    print "Hola Mundo"

it will run 10 times the process every Monday at 10:00 (AM) Attention: I'm using 0:00 to 23:59 style time.

Within the file:

name=HOLA_MUNDO
loops=10
repetition.frame=WEEKLY
repetition.period.day=Monday
repetition.period.time=10:00

it will run 10 times the process every Monday at 10:00 (AM)

The repetitions will start from the moment you run the script.

Specific Dates

TODO

About Reporting

TODO

Clone and install locally

Build from sources

Steps once you clone it from https://gitlab.com/Kotlirevsky/cronably:

1.- build : run python setup.py sdist bdist_wheel.

It will create the lib cronably.X.X.X.tar.gz in dist folder.

2.- In your proyect , if you have pipenv run:

pipenv install cronably-1.0.0.tar.gz

3.- You can check this example running

From From Pypi

2.- In your proyect , if you have pipenv run:

pip install cronably

3.- You can check this example running

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

cronably-1.1.0.tar.gz (9.7 kB view hashes)

Uploaded Source

Built Distribution

cronably-1.1.0-py2-none-any.whl (16.1 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