Mercurial > code > home > repos > homeauto
annotate service/mqtt_graph_bridge/tasks.py @ 1402:5373c5cc03c4
device configs
Ignore-this: 6e052d5533da601f72c6e7017b232e8c
darcs-hash:b179d80e8a1c78f71d851b78f2e54ab781d9d1e7
author | drewp <drewp@bigasterisk.com> |
---|---|
date | Tue, 23 Jul 2019 10:16:14 -0700 |
parents | a29a55f3429c |
children | 13b7e4de3824 |
rev | line source |
---|---|
1384
a29a55f3429c
mqtt_graph_bridge to new build rules and to py3
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
1 from invoke import task |
a29a55f3429c
mqtt_graph_bridge to new build rules and to py3
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
2 |
a29a55f3429c
mqtt_graph_bridge to new build rules and to py3
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
3 JOB = 'mqtt_graph_bridge' |
a29a55f3429c
mqtt_graph_bridge to new build rules and to py3
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
4 PORT = 10008 |
a29a55f3429c
mqtt_graph_bridge to new build rules and to py3
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
5 TAG = f'bang6:5000/{JOB}_x86:latest' |
a29a55f3429c
mqtt_graph_bridge to new build rules and to py3
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
6 |
a29a55f3429c
mqtt_graph_bridge to new build rules and to py3
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
7 @task |
a29a55f3429c
mqtt_graph_bridge to new build rules and to py3
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
8 def build_image(ctx): |
a29a55f3429c
mqtt_graph_bridge to new build rules and to py3
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
9 ctx.run(f'docker build --network=host -t {TAG} .') |
a29a55f3429c
mqtt_graph_bridge to new build rules and to py3
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
10 |
a29a55f3429c
mqtt_graph_bridge to new build rules and to py3
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
11 @task(pre=[build_image]) |
a29a55f3429c
mqtt_graph_bridge to new build rules and to py3
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
12 def push_image(ctx): |
a29a55f3429c
mqtt_graph_bridge to new build rules and to py3
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
13 ctx.run(f'docker push {TAG}') |
a29a55f3429c
mqtt_graph_bridge to new build rules and to py3
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
14 |
a29a55f3429c
mqtt_graph_bridge to new build rules and to py3
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
15 @task(pre=[build_image]) |
a29a55f3429c
mqtt_graph_bridge to new build rules and to py3
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
16 def shell(ctx): |
a29a55f3429c
mqtt_graph_bridge to new build rules and to py3
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
17 ctx.run(f'docker run --name={JOB}_shell --rm -it --cap-add SYS_PTRACE --net=host {TAG} /bin/bash', pty=True) |
a29a55f3429c
mqtt_graph_bridge to new build rules and to py3
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
18 |
a29a55f3429c
mqtt_graph_bridge to new build rules and to py3
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
19 @task(pre=[build_image]) |
a29a55f3429c
mqtt_graph_bridge to new build rules and to py3
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
20 def local_run(ctx): |
a29a55f3429c
mqtt_graph_bridge to new build rules and to py3
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
21 ctx.run(f'docker run --name={JOB}_local --rm -it --net=host {TAG} python3 mqtt_graph_bridge.py -v', pty=True) |
a29a55f3429c
mqtt_graph_bridge to new build rules and to py3
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
22 |
a29a55f3429c
mqtt_graph_bridge to new build rules and to py3
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
23 @task(pre=[push_image]) |
a29a55f3429c
mqtt_graph_bridge to new build rules and to py3
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
24 def redeploy(ctx): |
a29a55f3429c
mqtt_graph_bridge to new build rules and to py3
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
25 ctx.run(f'supervisorctl -s http://bang:9001/ restart {JOB}_{PORT}') |
a29a55f3429c
mqtt_graph_bridge to new build rules and to py3
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
26 |
a29a55f3429c
mqtt_graph_bridge to new build rules and to py3
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
27 @task |
a29a55f3429c
mqtt_graph_bridge to new build rules and to py3
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
28 def program_board_over_usb(ctx): |
a29a55f3429c
mqtt_graph_bridge to new build rules and to py3
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
29 tag = 'esphome/esphome' |
a29a55f3429c
mqtt_graph_bridge to new build rules and to py3
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
30 ctx.run(f"docker run --rm -v `pwd`:/config --device=/dev/ttyUSB0 -it {tag} door.yaml run", pty=True) |
a29a55f3429c
mqtt_graph_bridge to new build rules and to py3
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
31 # config_skylight.yaml run --no-logs |
a29a55f3429c
mqtt_graph_bridge to new build rules and to py3
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
32 |
a29a55f3429c
mqtt_graph_bridge to new build rules and to py3
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
33 @task |
a29a55f3429c
mqtt_graph_bridge to new build rules and to py3
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
34 def monitor_usb(ctx): |
a29a55f3429c
mqtt_graph_bridge to new build rules and to py3
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
35 tag = 'esphome/esphome' |
a29a55f3429c
mqtt_graph_bridge to new build rules and to py3
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
36 ctx.run(f"docker run --rm -v `pwd`:/config --device=/dev/ttyUSB0 -it {tag} door.yaml logs", pty=True) |
a29a55f3429c
mqtt_graph_bridge to new build rules and to py3
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
37 |
a29a55f3429c
mqtt_graph_bridge to new build rules and to py3
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
38 @task |
a29a55f3429c
mqtt_graph_bridge to new build rules and to py3
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
39 def tail_mqtt(ctx): |
a29a55f3429c
mqtt_graph_bridge to new build rules and to py3
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
40 ctx.run(f'mosquitto_sub -h bang -p 10010 -d -v -t \#') |
a29a55f3429c
mqtt_graph_bridge to new build rules and to py3
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
41 |
a29a55f3429c
mqtt_graph_bridge to new build rules and to py3
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
42 |
a29a55f3429c
mqtt_graph_bridge to new build rules and to py3
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
43 |
a29a55f3429c
mqtt_graph_bridge to new build rules and to py3
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
44 |
a29a55f3429c
mqtt_graph_bridge to new build rules and to py3
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
45 |
a29a55f3429c
mqtt_graph_bridge to new build rules and to py3
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
46 |
a29a55f3429c
mqtt_graph_bridge to new build rules and to py3
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
47 |
a29a55f3429c
mqtt_graph_bridge to new build rules and to py3
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
48 |
a29a55f3429c
mqtt_graph_bridge to new build rules and to py3
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
49 |
a29a55f3429c
mqtt_graph_bridge to new build rules and to py3
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
50 |