README.md 814 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
15
16
17
18
19
20
21
from crontabs import CronTabs
from hc import HealthcheckCredentials, Healthchecks

cred = HealthcheckCredentials(
           api_url='https://hc.example.com/api/v1/',
           api_key='mysecretapikey'
        )
Bram Daams's avatar
Bram Daams committed
22

23
24
h = Healthchecks(cred)
h.PrintStatus()
25
26
27

jobs = CronTabs().all.find_command('JOB_ID')
for job in jobs:
28
    check = h.find_check(job)
29
    if check:
30
        h.update_check(check, job)
31
    else:
32
        h.new_check(job)
Bram Daams's avatar
Bram Daams committed
33
```
Bram Daams's avatar
Bram Daams committed
34
35
36
37
38
39
40
41
42
43

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