README.md 733 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
from hc import hcCred, Healthchecks
Bram Daams's avatar
Bram Daams committed
16
17

cred = hcCred('https://hc.example.com/api/v1/', 'mysecretapikey')
18
19
h = Healthchecks(cred)
h.PrintStatus()
20
21
22
23

# scan jobs that want to use SCH
jobs = CronTabs().all.find_command('JOB_ID')
for job in jobs:
24
25
26
27
28
    check = h.FindCheck(job)
    if check:
        h.UpdateCheck(check, job)
    else:
        h.NewCheck(job)
Bram Daams's avatar
Bram Daams committed
29
```
Bram Daams's avatar
Bram Daams committed
30
31
32
33
34
35
36
37
38
39

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
40
41
## Documentation
* python-crontab <https://pypi.org/project/python-crontab/>