]> rtime.felk.cvut.cz Git - hubacji1/coffee-getter.git/blob - README.md
Update readme with systemd timers info
[hubacji1/coffee-getter.git] / README.md
1 # Coffeebot getter
2 Somehow friendly API to get and share coffee related data from database.
3
4 # Development
5 ## Timers
6 For running tasks periodically, please see [Timers][6] and [User][7] pages
7 about systemd on archlinux wiki.
8
9 The example `top5_mate_stats.service`:
10 ```
11 [Unit]
12 Description=Run top 5 Mate drinkers stats
13
14 [Service]
15 Environment=PYTHONPATH=/path/to/coffee-getter/repo/
16 ExecStart=/path/to/coffee-getter/repo/run/top5_mate_stats.py
17 ```
18
19 The example `top5_mate_stats.timer`:
20 ```
21 [Unit]
22 Description=Run top 5 Mate drinkers stats each Mon 9am
23
24 [Timer]
25 OnCalendar=Mon *-*-* 09:00:00
26 Persistent=true
27
28 [Install]
29 WantedBy=timers.target
30 ```
31
32 Both files must be stored in `~/.config/systemd/user/` directory.
33
34 Then enable timer and service by:
35 ```
36 systemctl --user enable top5_mate_stats.timer
37 systemctl --user enable top5_mate_stats.service
38 ```
39
40 And start timer by:
41 ```
42 systemctl --user start top5_mate_stats.timer
43 ```
44
45 # Contribute
46 ## Code
47 For quick orientation see the [changelog][1].
48
49 Please, think about [The seven rules of a great Git commit message][2] when
50 making commit. The project use [OneFlow][3] branching model with the `master`
51 branch as the branch where the development happens.
52
53 ## TDD
54 Test Driven Development (TDD) is used in this project. Each *feature* **must**
55 start with adding test and all the tests **must** pass before merge to the
56 *master*.
57
58 Run the tests by:
59 ```
60 python3 -m unittest discover ut/
61 ```
62
63 See [unittest][5] for start.
64
65 ## Database
66 By default, sqlite3 `coffee.db` file is needed. You may create testing copy of
67 database by:
68 ```
69 python3 -c '
70 from ut.test_db import create_test_db
71 create_test_db("coffee.db")
72 '
73 ```
74
75 Database is needed to pass the tests.
76
77 ## License
78 This project is developed under [GNU GPLv3 license][4].
79
80 [1]: ./CHANGELOG.md
81 [2]: https://chris.beams.io/posts/git-commit/
82 [3]: http://endoflineblog.com/oneflow-a-git-branching-model-and-workflow
83 [4]: ./LICENSE
84 [5]: https://docs.python.org/3.5/library/unittest.html
85 [6]: https://wiki.archlinux.org/index.php/Systemd/Timers
86 [7]: https://wiki.archlinux.org/index.php/Systemd/User