Mercurial > code > home > repos > homeauto
annotate service/frontDoorLock/tasks.py @ 1370:a6902e4587f6
update esphome version. rename esp board to be distinct from pi board. new invoke rules for esp programming
Ignore-this: 106acca04ac1012ac21a434692a4d515
darcs-hash:2f54636654af549b195ed8c1aaec8c12406a5eec
author | drewp <drewp@bigasterisk.com> |
---|---|
date | Sun, 05 May 2019 22:43:14 -0700 |
parents | 5836e88a0287 |
children | fecbac537f63 |
rev | line source |
---|---|
1366 | 1 from invoke import task |
2 | |
3 JOB = 'front_door_lock' | |
4 PORT = 10011 | |
5 TAG = f'bang6:5000/{JOB}_x86:latest' | |
6 ANSIBLE_TAG = 'door' | |
7 | |
8 @task | |
9 def build_image(ctx): | |
10 ctx.run(f'docker build --network=host -t {TAG} .') | |
11 | |
12 @task(pre=[build_image]) | |
13 def push_image(ctx): | |
14 ctx.run(f'docker push {TAG}') | |
15 | |
16 @task(pre=[build_image]) | |
17 def shell(ctx): | |
18 ctx.run(f'docker run --name={JOB}_shell --rm -it --cap-add SYS_PTRACE --net=host {TAG} /bin/bash', pty=True) | |
19 | |
20 @task(pre=[build_image]) | |
21 def local_run(ctx): | |
22 ctx.run(f'docker run --name={JOB}_local --rm -it --net=host -v `pwd`/index.html:/opt/index.html {TAG} python3 ./front_door_lock.py -v', pty=True) | |
23 | |
24 @task(pre=[push_image]) | |
25 def redeploy(ctx): | |
26 ctx.run(f'sudo /my/proj/ansible/playbook -l bang -t {ANSIBLE_TAG}') | |
27 ctx.run(f'supervisorctl -s http://bang:9001/ restart {JOB}_{PORT}') | |
1370
a6902e4587f6
update esphome version. rename esp board to be distinct from pi board. new invoke rules for esp programming
drewp <drewp@bigasterisk.com>
parents:
1366
diff
changeset
|
28 |
a6902e4587f6
update esphome version. rename esp board to be distinct from pi board. new invoke rules for esp programming
drewp <drewp@bigasterisk.com>
parents:
1366
diff
changeset
|
29 @task |
a6902e4587f6
update esphome version. rename esp board to be distinct from pi board. new invoke rules for esp programming
drewp <drewp@bigasterisk.com>
parents:
1366
diff
changeset
|
30 def program_board_over_usb(ctx): |
a6902e4587f6
update esphome version. rename esp board to be distinct from pi board. new invoke rules for esp programming
drewp <drewp@bigasterisk.com>
parents:
1366
diff
changeset
|
31 tag = 'esphome/esphome' |
a6902e4587f6
update esphome version. rename esp board to be distinct from pi board. new invoke rules for esp programming
drewp <drewp@bigasterisk.com>
parents:
1366
diff
changeset
|
32 ctx.run(f"docker pull {tag}") |
a6902e4587f6
update esphome version. rename esp board to be distinct from pi board. new invoke rules for esp programming
drewp <drewp@bigasterisk.com>
parents:
1366
diff
changeset
|
33 ctx.run(f"docker run --rm -v `pwd`:/config --device=/dev/ttyUSB0 -it {tag} door.yaml run", pty=True) |
a6902e4587f6
update esphome version. rename esp board to be distinct from pi board. new invoke rules for esp programming
drewp <drewp@bigasterisk.com>
parents:
1366
diff
changeset
|
34 |
a6902e4587f6
update esphome version. rename esp board to be distinct from pi board. new invoke rules for esp programming
drewp <drewp@bigasterisk.com>
parents:
1366
diff
changeset
|
35 @task |
a6902e4587f6
update esphome version. rename esp board to be distinct from pi board. new invoke rules for esp programming
drewp <drewp@bigasterisk.com>
parents:
1366
diff
changeset
|
36 def monitor_usb(ctx): |
a6902e4587f6
update esphome version. rename esp board to be distinct from pi board. new invoke rules for esp programming
drewp <drewp@bigasterisk.com>
parents:
1366
diff
changeset
|
37 tag = 'esphome/esphome' |
a6902e4587f6
update esphome version. rename esp board to be distinct from pi board. new invoke rules for esp programming
drewp <drewp@bigasterisk.com>
parents:
1366
diff
changeset
|
38 ctx.run(f"docker run --rm -v `pwd`:/config --device=/dev/ttyUSB0 -it {tag} door.yaml logs", pty=True) |