README.md 959 Bytes
Newer Older
Bram Daams's avatar
Bram Daams committed
1
2
# sch

Bram Daams's avatar
Bram Daams committed
3
4
SmartCronHelper

Bram Daams's avatar
Bram Daams committed
5
6
7
8
## Install
``` console
$ python -m venv venv
$ . venv/bin/activate
Bram Daams's avatar
Bram Daams committed
9
$ pip install .
Bram Daams's avatar
Bram Daams committed
10
11
12
13
```

## Test
For now, create a file `test.py`
Bram Daams's avatar
Bram Daams committed
14
``` python
Bram Daams's avatar
Bram Daams committed
15
16
17
18
"""
Testing hc.py
"""

19
from crontabs import CronTabs
Bram Daams's avatar
Bram Daams committed
20

21
22
23
from hc import HealthcheckCredentials, Healthchecks

cred = HealthcheckCredentials(
Bram Daams's avatar
Bram Daams committed
24
25
26
27
28
29
30
31
    api_url='https://hc.example.com/api/v1/',
    api_key='mysecretapikey'
    )

CRED = HealthcheckCredentials(
    api_url='https://cronmon.science.ru.nl/api/v1/',
    api_key='AbuQXRDCqBk_Q9SiPRfmJA2KtvbNWKx4'
    )
Bram Daams's avatar
Bram Daams committed
32

Bram Daams's avatar
Bram Daams committed
33
34
H = Healthchecks(CRED)
H.print_status()
35

Bram Daams's avatar
Bram Daams committed
36
37
38
JOBS = CronTabs().all.find_command('JOB_ID')
for job in JOBS:
    check = H.find_check(job)
39
    if check:
Bram Daams's avatar
Bram Daams committed
40
        H.update_check(check, job)
41
    else:
Bram Daams's avatar
Bram Daams committed
42
        H.new_check(job)
Bram Daams's avatar
Bram Daams committed
43
```
Bram Daams's avatar
Bram Daams committed
44
45
46
47
48
49
50
51
52
53

And run it within the virtual environment

## Syntax check
In the virtual environment:
``` console
$ pip install flake8
$ flake8 *py
```

Bram Daams's avatar
Bram Daams committed
54
55
## Documentation
* python-crontab <https://pypi.org/project/python-crontab/>