annotate service/frontDoorLock/tasks.py @ 1456:a81def58ecfb

index page rewrite. mqtt subscribe update. new store/events graph uri Ignore-this: f0e59d3487ebfc90f8f4a830a7084023 darcs-hash:45bd18fecdb41c90b786a9e5909111e4a17bfcbe
author drewp <drewp@bigasterisk.com>
date Wed, 25 Sep 2019 17:36:44 -0700
parents fecbac537f63
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1366
5836e88a0287 py3 and new build
drewp <drewp@bigasterisk.com>
parents:
diff changeset
1 from invoke import task
5836e88a0287 py3 and new build
drewp <drewp@bigasterisk.com>
parents:
diff changeset
2
5836e88a0287 py3 and new build
drewp <drewp@bigasterisk.com>
parents:
diff changeset
3 JOB = 'front_door_lock'
5836e88a0287 py3 and new build
drewp <drewp@bigasterisk.com>
parents:
diff changeset
4 PORT = 10011
5836e88a0287 py3 and new build
drewp <drewp@bigasterisk.com>
parents:
diff changeset
5 TAG = f'bang6:5000/{JOB}_x86:latest'
5836e88a0287 py3 and new build
drewp <drewp@bigasterisk.com>
parents:
diff changeset
6 ANSIBLE_TAG = 'door'
5836e88a0287 py3 and new build
drewp <drewp@bigasterisk.com>
parents:
diff changeset
7
5836e88a0287 py3 and new build
drewp <drewp@bigasterisk.com>
parents:
diff changeset
8 @task
5836e88a0287 py3 and new build
drewp <drewp@bigasterisk.com>
parents:
diff changeset
9 def build_image(ctx):
5836e88a0287 py3 and new build
drewp <drewp@bigasterisk.com>
parents:
diff changeset
10 ctx.run(f'docker build --network=host -t {TAG} .')
5836e88a0287 py3 and new build
drewp <drewp@bigasterisk.com>
parents:
diff changeset
11
5836e88a0287 py3 and new build
drewp <drewp@bigasterisk.com>
parents:
diff changeset
12 @task(pre=[build_image])
5836e88a0287 py3 and new build
drewp <drewp@bigasterisk.com>
parents:
diff changeset
13 def push_image(ctx):
5836e88a0287 py3 and new build
drewp <drewp@bigasterisk.com>
parents:
diff changeset
14 ctx.run(f'docker push {TAG}')
5836e88a0287 py3 and new build
drewp <drewp@bigasterisk.com>
parents:
diff changeset
15
5836e88a0287 py3 and new build
drewp <drewp@bigasterisk.com>
parents:
diff changeset
16 @task(pre=[build_image])
5836e88a0287 py3 and new build
drewp <drewp@bigasterisk.com>
parents:
diff changeset
17 def shell(ctx):
1456
a81def58ecfb index page rewrite. mqtt subscribe update. new store/events graph uri
drewp <drewp@bigasterisk.com>
parents: 1378
diff changeset
18 ctx.run(f'docker run --name={JOB}_shell --rm -it --cap-add SYS_PTRACE --net=host '
a81def58ecfb index page rewrite. mqtt subscribe update. new store/events graph uri
drewp <drewp@bigasterisk.com>
parents: 1378
diff changeset
19 f' -v `pwd`/../../stubs:/opt/stubs'
a81def58ecfb index page rewrite. mqtt subscribe update. new store/events graph uri
drewp <drewp@bigasterisk.com>
parents: 1378
diff changeset
20 f' {TAG} /bin/bash', pty=True)
1366
5836e88a0287 py3 and new build
drewp <drewp@bigasterisk.com>
parents:
diff changeset
21
5836e88a0287 py3 and new build
drewp <drewp@bigasterisk.com>
parents:
diff changeset
22 @task(pre=[build_image])
5836e88a0287 py3 and new build
drewp <drewp@bigasterisk.com>
parents:
diff changeset
23 def local_run(ctx):
5836e88a0287 py3 and new build
drewp <drewp@bigasterisk.com>
parents:
diff changeset
24 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)
5836e88a0287 py3 and new build
drewp <drewp@bigasterisk.com>
parents:
diff changeset
25
5836e88a0287 py3 and new build
drewp <drewp@bigasterisk.com>
parents:
diff changeset
26 @task(pre=[push_image])
5836e88a0287 py3 and new build
drewp <drewp@bigasterisk.com>
parents:
diff changeset
27 def redeploy(ctx):
5836e88a0287 py3 and new build
drewp <drewp@bigasterisk.com>
parents:
diff changeset
28 ctx.run(f'sudo /my/proj/ansible/playbook -l bang -t {ANSIBLE_TAG}')
5836e88a0287 py3 and new build
drewp <drewp@bigasterisk.com>
parents:
diff changeset
29 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
30
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 @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
32 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
33 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
34 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
35 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
36
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 @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
38 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
39 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
40 ctx.run(f"docker run --rm -v `pwd`:/config --device=/dev/ttyUSB0 -it {tag} door.yaml logs", pty=True)
1378
fecbac537f63 faster keepalive from esp chip. report aliveness into the graph. more programming tasks in tasks.py
drewp <drewp@bigasterisk.com>
parents: 1370
diff changeset
41
fecbac537f63 faster keepalive from esp chip. report aliveness into the graph. more programming tasks in tasks.py
drewp <drewp@bigasterisk.com>
parents: 1370
diff changeset
42 @task
fecbac537f63 faster keepalive from esp chip. report aliveness into the graph. more programming tasks in tasks.py
drewp <drewp@bigasterisk.com>
parents: 1370
diff changeset
43 def tail_mqtt(ctx):
fecbac537f63 faster keepalive from esp chip. report aliveness into the graph. more programming tasks in tasks.py
drewp <drewp@bigasterisk.com>
parents: 1370
diff changeset
44 ctx.run(f'mosquitto_sub -h bang -p 10010 -d -v -t \#')
fecbac537f63 faster keepalive from esp chip. report aliveness into the graph. more programming tasks in tasks.py
drewp <drewp@bigasterisk.com>
parents: 1370
diff changeset
45
fecbac537f63 faster keepalive from esp chip. report aliveness into the graph. more programming tasks in tasks.py
drewp <drewp@bigasterisk.com>
parents: 1370
diff changeset
46 @task
fecbac537f63 faster keepalive from esp chip. report aliveness into the graph. more programming tasks in tasks.py
drewp <drewp@bigasterisk.com>
parents: 1370
diff changeset
47 def mqtt_force_open(ctx):
fecbac537f63 faster keepalive from esp chip. report aliveness into the graph. more programming tasks in tasks.py
drewp <drewp@bigasterisk.com>
parents: 1370
diff changeset
48 ctx.run(f'mosquitto_pub -h bang -p 10010 -t frontdoorlock/switch/strike/command -m ON')
fecbac537f63 faster keepalive from esp chip. report aliveness into the graph. more programming tasks in tasks.py
drewp <drewp@bigasterisk.com>
parents: 1370
diff changeset
49
fecbac537f63 faster keepalive from esp chip. report aliveness into the graph. more programming tasks in tasks.py
drewp <drewp@bigasterisk.com>
parents: 1370
diff changeset
50 @task
fecbac537f63 faster keepalive from esp chip. report aliveness into the graph. more programming tasks in tasks.py
drewp <drewp@bigasterisk.com>
parents: 1370
diff changeset
51 def mqtt_force_lock(ctx):
fecbac537f63 faster keepalive from esp chip. report aliveness into the graph. more programming tasks in tasks.py
drewp <drewp@bigasterisk.com>
parents: 1370
diff changeset
52 ctx.run(f'mosquitto_pub -h bang -p 10010 -t frontdoorlock/switch/strike/command -m OFF')
fecbac537f63 faster keepalive from esp chip. report aliveness into the graph. more programming tasks in tasks.py
drewp <drewp@bigasterisk.com>
parents: 1370
diff changeset
53
1456
a81def58ecfb index page rewrite. mqtt subscribe update. new store/events graph uri
drewp <drewp@bigasterisk.com>
parents: 1378
diff changeset
54
a81def58ecfb index page rewrite. mqtt subscribe update. new store/events graph uri
drewp <drewp@bigasterisk.com>
parents: 1378
diff changeset
55 @task(pre=[build_image])
a81def58ecfb index page rewrite. mqtt subscribe update. new store/events graph uri
drewp <drewp@bigasterisk.com>
parents: 1378
diff changeset
56 def mypy(ctx):
a81def58ecfb index page rewrite. mqtt subscribe update. new store/events graph uri
drewp <drewp@bigasterisk.com>
parents: 1378
diff changeset
57 ctx.run(f'docker run --rm -it --name={JOB}_mypy --net=host'
a81def58ecfb index page rewrite. mqtt subscribe update. new store/events graph uri
drewp <drewp@bigasterisk.com>
parents: 1378
diff changeset
58 f' -v `pwd`/.mypy_cache:/opt/.mypy_cache'
a81def58ecfb index page rewrite. mqtt subscribe update. new store/events graph uri
drewp <drewp@bigasterisk.com>
parents: 1378
diff changeset
59 f' -v `pwd`/../../stubs:/opt/stubs'
a81def58ecfb index page rewrite. mqtt subscribe update. new store/events graph uri
drewp <drewp@bigasterisk.com>
parents: 1378
diff changeset
60 f' -e MYPYPATH=/opt/stubs'
a81def58ecfb index page rewrite. mqtt subscribe update. new store/events graph uri
drewp <drewp@bigasterisk.com>
parents: 1378
diff changeset
61 f' {TAG}'
a81def58ecfb index page rewrite. mqtt subscribe update. new store/events graph uri
drewp <drewp@bigasterisk.com>
parents: 1378
diff changeset
62 f' /usr/local/bin/mypy -m front_door_lock', pty=True)
a81def58ecfb index page rewrite. mqtt subscribe update. new store/events graph uri
drewp <drewp@bigasterisk.com>
parents: 1378
diff changeset
63