annotate service/piNode/tasks.py @ 1431:af2d0249a2cc

wip for pytype support and separate device run loops on piNode Ignore-this: 9aa9a3a7e715afefbc858050e02c4c62 darcs-hash:998d048d88b8cbc9e5fcd7576dec8687a9960e8c
author drewp <drewp@bigasterisk.com>
date Sat, 10 Aug 2019 23:33:50 -0700
parents 445e24e8c8bb
children 0da337780f22
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1355
f2159312b0e7 update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp <drewp@bigasterisk.com>
parents:
diff changeset
1 from invoke import task
f2159312b0e7 update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp <drewp@bigasterisk.com>
parents:
diff changeset
2
f2159312b0e7 update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp <drewp@bigasterisk.com>
parents:
diff changeset
3 JOB = 'piNode'
f2159312b0e7 update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp <drewp@bigasterisk.com>
parents:
diff changeset
4 PORT = 9059
f2159312b0e7 update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp <drewp@bigasterisk.com>
parents:
diff changeset
5 TAG = f'bang6:5000/{JOB.lower()}_pi:latest'
f2159312b0e7 update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp <drewp@bigasterisk.com>
parents:
diff changeset
6 ANSIBLE_TAG = 'raspi_io_node'
f2159312b0e7 update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp <drewp@bigasterisk.com>
parents:
diff changeset
7
f2159312b0e7 update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp <drewp@bigasterisk.com>
parents:
diff changeset
8 @task
f2159312b0e7 update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp <drewp@bigasterisk.com>
parents:
diff changeset
9 def build_image(ctx):
f2159312b0e7 update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp <drewp@bigasterisk.com>
parents:
diff changeset
10 ctx.run(f'docker build --network=host -t {TAG} .')
f2159312b0e7 update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp <drewp@bigasterisk.com>
parents:
diff changeset
11
1431
af2d0249a2cc wip for pytype support and separate device run loops on piNode
drewp <drewp@bigasterisk.com>
parents: 1430
diff changeset
12 @task
af2d0249a2cc wip for pytype support and separate device run loops on piNode
drewp <drewp@bigasterisk.com>
parents: 1430
diff changeset
13 def build_image_check(ctx):
af2d0249a2cc wip for pytype support and separate device run loops on piNode
drewp <drewp@bigasterisk.com>
parents: 1430
diff changeset
14 ctx.run(f'docker build --network=host -f Dockerfile.check -t bang6:5000/pinode_check:latest .')
af2d0249a2cc wip for pytype support and separate device run loops on piNode
drewp <drewp@bigasterisk.com>
parents: 1430
diff changeset
15
1355
f2159312b0e7 update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp <drewp@bigasterisk.com>
parents:
diff changeset
16 @task(pre=[build_image])
f2159312b0e7 update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp <drewp@bigasterisk.com>
parents:
diff changeset
17 def push_image(ctx):
f2159312b0e7 update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp <drewp@bigasterisk.com>
parents:
diff changeset
18 ctx.run(f'docker push {TAG}')
f2159312b0e7 update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp <drewp@bigasterisk.com>
parents:
diff changeset
19
f2159312b0e7 update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp <drewp@bigasterisk.com>
parents:
diff changeset
20 @task(pre=[build_image])
f2159312b0e7 update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp <drewp@bigasterisk.com>
parents:
diff changeset
21 def shell(ctx):
1430
445e24e8c8bb lib upgrades; fix a static http server path
drewp <drewp@bigasterisk.com>
parents: 1355
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)
1355
f2159312b0e7 update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp <drewp@bigasterisk.com>
parents:
diff changeset
23
1431
af2d0249a2cc wip for pytype support and separate device run loops on piNode
drewp <drewp@bigasterisk.com>
parents: 1430
diff changeset
24 @task(pre=[build_image_check])
af2d0249a2cc wip for pytype support and separate device run loops on piNode
drewp <drewp@bigasterisk.com>
parents: 1430
diff changeset
25 def check(ctx):
af2d0249a2cc wip for pytype support and separate device run loops on piNode
drewp <drewp@bigasterisk.com>
parents: 1430
diff changeset
26 ctx.run(f'docker run --name={JOB}_check --rm -it -v `pwd`:/opt --net=host bang6:5000/pinode_check:latest pytype -d import-error mypkg/piNode.py', pty=True)
af2d0249a2cc wip for pytype support and separate device run loops on piNode
drewp <drewp@bigasterisk.com>
parents: 1430
diff changeset
27
af2d0249a2cc wip for pytype support and separate device run loops on piNode
drewp <drewp@bigasterisk.com>
parents: 1430
diff changeset
28 @task(pre=[build_image_check])
af2d0249a2cc wip for pytype support and separate device run loops on piNode
drewp <drewp@bigasterisk.com>
parents: 1430
diff changeset
29 def check_shell(ctx):
af2d0249a2cc wip for pytype support and separate device run loops on piNode
drewp <drewp@bigasterisk.com>
parents: 1430
diff changeset
30 ctx.run(f'docker run --name={JOB}_check --rm -it -v `pwd`:/opt --net=host bang6:5000/pinode_check:latest /bin/bash', pty=True)
af2d0249a2cc wip for pytype support and separate device run loops on piNode
drewp <drewp@bigasterisk.com>
parents: 1430
diff changeset
31
1355
f2159312b0e7 update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp <drewp@bigasterisk.com>
parents:
diff changeset
32
f2159312b0e7 update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp <drewp@bigasterisk.com>
parents:
diff changeset
33 @task(pre=[build_image])
f2159312b0e7 update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp <drewp@bigasterisk.com>
parents:
diff changeset
34 def local_run(ctx):
f2159312b0e7 update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp <drewp@bigasterisk.com>
parents:
diff changeset
35 ctx.run(f'docker run --name={JOB}_local --rm -it {TAG} python ./piNode.py -v', pty=True)
f2159312b0e7 update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp <drewp@bigasterisk.com>
parents:
diff changeset
36
f2159312b0e7 update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp <drewp@bigasterisk.com>
parents:
diff changeset
37 @task(pre=[push_image])
f2159312b0e7 update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp <drewp@bigasterisk.com>
parents:
diff changeset
38 def redeploy(ctx):
f2159312b0e7 update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp <drewp@bigasterisk.com>
parents:
diff changeset
39 ctx.run(f'sudo /my/proj/ansible/playbook -l pi -t {ANSIBLE_TAG}')
f2159312b0e7 update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp <drewp@bigasterisk.com>
parents:
diff changeset
40
f2159312b0e7 update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp <drewp@bigasterisk.com>
parents:
diff changeset
41 @task
f2159312b0e7 update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp <drewp@bigasterisk.com>
parents:
diff changeset
42 def push_config(ctx):
f2159312b0e7 update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp <drewp@bigasterisk.com>
parents:
diff changeset
43 ctx.run(f'docker run --rm --net=host -v `pwd`/config:/opt/config bang6:5000/arduino_node python pushConfig.py pi/')