annotate service/piNode/tasks.py @ 1754:92999dfbf321 default tip

add shelly support
author drewp@bigasterisk.com
date Tue, 04 Jun 2024 13:03:43 -0700
parents 9d074317e16a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
552
98384c3ccd33 update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp@bigasterisk.com
parents: 466
diff changeset
1 from invoke import task
98384c3ccd33 update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp@bigasterisk.com
parents: 466
diff changeset
2
1681
9d074317e16a checkpoint service/piNode
drewp@bigasterisk.com
parents: 722
diff changeset
3 JOB = 'pi_node'
552
98384c3ccd33 update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp@bigasterisk.com
parents: 466
diff changeset
4 PORT = 9059
1681
9d074317e16a checkpoint service/piNode
drewp@bigasterisk.com
parents: 722
diff changeset
5 TAG = f'bang5:5000/{JOB.lower()}_pi:latest'
552
98384c3ccd33 update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp@bigasterisk.com
parents: 466
diff changeset
6 ANSIBLE_TAG = 'raspi_io_node'
365
cb3738b1a15a pi_base moves to base image project
drewp@bigasterisk.com
parents: 347
diff changeset
7
552
98384c3ccd33 update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp@bigasterisk.com
parents: 466
diff changeset
8 @task
98384c3ccd33 update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp@bigasterisk.com
parents: 466
diff changeset
9 def build_image(ctx):
98384c3ccd33 update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp@bigasterisk.com
parents: 466
diff changeset
10 ctx.run(f'docker build --network=host -t {TAG} .')
338
f64e20d3407e RgbPixelsAnimation and docker build updates
drewp@bigasterisk.com
parents:
diff changeset
11
628
accbbd521ecd wip for pytype support and separate device run loops on piNode
drewp@bigasterisk.com
parents: 627
diff changeset
12 @task
accbbd521ecd wip for pytype support and separate device run loops on piNode
drewp@bigasterisk.com
parents: 627
diff changeset
13 def build_image_check(ctx):
1681
9d074317e16a checkpoint service/piNode
drewp@bigasterisk.com
parents: 722
diff changeset
14 ctx.run(f'docker build --network=host -f Dockerfile.check -t bang6:5000/pi_node_check:latest .')
628
accbbd521ecd wip for pytype support and separate device run loops on piNode
drewp@bigasterisk.com
parents: 627
diff changeset
15
552
98384c3ccd33 update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp@bigasterisk.com
parents: 466
diff changeset
16 @task(pre=[build_image])
98384c3ccd33 update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp@bigasterisk.com
parents: 466
diff changeset
17 def push_image(ctx):
98384c3ccd33 update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp@bigasterisk.com
parents: 466
diff changeset
18 ctx.run(f'docker push {TAG}')
338
f64e20d3407e RgbPixelsAnimation and docker build updates
drewp@bigasterisk.com
parents:
diff changeset
19
552
98384c3ccd33 update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp@bigasterisk.com
parents: 466
diff changeset
20 @task(pre=[build_image])
98384c3ccd33 update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp@bigasterisk.com
parents: 466
diff changeset
21 def shell(ctx):
627
c3f0a98fa65d lib upgrades; fix a static http server path
drewp@bigasterisk.com
parents: 552
diff changeset
22 ctx.run(f'docker run --name={JOB}_shell --rm -it --cap-add SYS_PTRACE --net=host --uts=host --cap-add SYS_RAWIO --device /dev/mem --privileged {TAG} /bin/bash', pty=True)
347
97f5cbcac00b pi read config over etcd
drewp@bigasterisk.com
parents: 338
diff changeset
23
628
accbbd521ecd wip for pytype support and separate device run loops on piNode
drewp@bigasterisk.com
parents: 627
diff changeset
24 @task(pre=[build_image_check])
accbbd521ecd wip for pytype support and separate device run loops on piNode
drewp@bigasterisk.com
parents: 627
diff changeset
25 def check(ctx):
1681
9d074317e16a checkpoint service/piNode
drewp@bigasterisk.com
parents: 722
diff changeset
26 ctx.run(f'docker run --name={JOB}_check --rm -it -v `pwd`:/opt --net=host bang6:5000/pi_node_check:latest pytype -d import-error mypkg/piNode.py', pty=True)
628
accbbd521ecd wip for pytype support and separate device run loops on piNode
drewp@bigasterisk.com
parents: 627
diff changeset
27
accbbd521ecd wip for pytype support and separate device run loops on piNode
drewp@bigasterisk.com
parents: 627
diff changeset
28 @task(pre=[build_image_check])
accbbd521ecd wip for pytype support and separate device run loops on piNode
drewp@bigasterisk.com
parents: 627
diff changeset
29 def check_shell(ctx):
1681
9d074317e16a checkpoint service/piNode
drewp@bigasterisk.com
parents: 722
diff changeset
30 ctx.run(f'docker run --name={JOB}_check --rm -it -v `pwd`:/opt --net=host bang6:5000/pi_node_check:latest /bin/bash', pty=True)
628
accbbd521ecd wip for pytype support and separate device run loops on piNode
drewp@bigasterisk.com
parents: 627
diff changeset
31
347
97f5cbcac00b pi read config over etcd
drewp@bigasterisk.com
parents: 338
diff changeset
32
552
98384c3ccd33 update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp@bigasterisk.com
parents: 466
diff changeset
33 @task(pre=[build_image])
98384c3ccd33 update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp@bigasterisk.com
parents: 466
diff changeset
34 def local_run(ctx):
98384c3ccd33 update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp@bigasterisk.com
parents: 466
diff changeset
35 ctx.run(f'docker run --name={JOB}_local --rm -it {TAG} python ./piNode.py -v', pty=True)
466
1122016d16eb stats handler, events output fix, build updaets
drewp@bigasterisk.com
parents: 365
diff changeset
36
1681
9d074317e16a checkpoint service/piNode
drewp@bigasterisk.com
parents: 722
diff changeset
37 @task(pre=[build_image_check])
9d074317e16a checkpoint service/piNode
drewp@bigasterisk.com
parents: 722
diff changeset
38 def auto_button_test(ctx):
9d074317e16a checkpoint service/piNode
drewp@bigasterisk.com
parents: 722
diff changeset
39 ctx.run(f'docker run --name={JOB}_button --rm -it --hostname demo -v `pwd`:/opt bang6:5000/pi_node_check:latest python3 -B ./auto_button_test.py', pty=True)
9d074317e16a checkpoint service/piNode
drewp@bigasterisk.com
parents: 722
diff changeset
40
552
98384c3ccd33 update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp@bigasterisk.com
parents: 466
diff changeset
41 @task(pre=[push_image])
98384c3ccd33 update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp@bigasterisk.com
parents: 466
diff changeset
42 def redeploy(ctx):
98384c3ccd33 update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp@bigasterisk.com
parents: 466
diff changeset
43 ctx.run(f'sudo /my/proj/ansible/playbook -l pi -t {ANSIBLE_TAG}')
98384c3ccd33 update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp@bigasterisk.com
parents: 466
diff changeset
44
98384c3ccd33 update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp@bigasterisk.com
parents: 466
diff changeset
45 @task
98384c3ccd33 update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp@bigasterisk.com
parents: 466
diff changeset
46 def push_config(ctx):
722
a93fbf0d0daa dep updates; graph url renames; and other build updates
drewp@bigasterisk.com
parents: 628
diff changeset
47 ctx.run(f'docker run --name={JOB}_config --rm --net=host --dns 10.2.0.1 --dns-search bigasterisk.com -v `pwd`/config:/opt/config bang6:5000/arduino_node python pushConfig.py pi/')