annotate service/mqtt_graph_bridge/tasks.py @ 1423:ba56263fe3b2

arduinonode to docker Ignore-this: 8f689c7491819bc47200018b517fd7de darcs-hash:e3602fc781c7b66e98ca950d5782ecc41e506bad
author drewp <drewp@bigasterisk.com>
date Wed, 07 Aug 2019 20:23:04 -0700
parents a29a55f3429c
children 13b7e4de3824
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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