Mercurial > code > home > repos > homeauto
annotate service/arduinoNode/pushConfig.py @ 1259:672a3d830e7f
arduinoNode: build updates, stats support, etc
Ignore-this: 39386eb7644e3cf522e0f72a874eadba
darcs-hash:b6fa9fbda226917dd3b94d8a87556c4cd6d51180
author | drewp <drewp@bigasterisk.com> |
---|---|
date | Sat, 20 Apr 2019 23:28:29 -0700 |
parents | 8b4eda2cf0bd |
children | 048a8df60e2e |
rev | line source |
---|---|
1138 | 1 from __future__ import division |
1148 | 2 import sys |
1139
db955e7943af
arduinonode reads config from etcd. use pushConfig.py to inform all nodes
drewp <drewp@bigasterisk.com>
parents:
1138
diff
changeset
|
3 import etcd3 |
db955e7943af
arduinonode reads config from etcd. use pushConfig.py to inform all nodes
drewp <drewp@bigasterisk.com>
parents:
1138
diff
changeset
|
4 |
1138 | 5 from twisted.python.filepath import FilePath |
6 | |
1259
672a3d830e7f
arduinoNode: build updates, stats support, etc
drewp <drewp@bigasterisk.com>
parents:
1148
diff
changeset
|
7 etcd = etcd3.client(host='bang6', port=9022) |
1138 | 8 |
1148 | 9 prefix, = sys.argv[1:] |
10 | |
1139
db955e7943af
arduinonode reads config from etcd. use pushConfig.py to inform all nodes
drewp <drewp@bigasterisk.com>
parents:
1138
diff
changeset
|
11 def main(): |
db955e7943af
arduinonode reads config from etcd. use pushConfig.py to inform all nodes
drewp <drewp@bigasterisk.com>
parents:
1138
diff
changeset
|
12 existing = set(md.key for v, md in etcd.get_prefix(prefix)) |
1138 | 13 written = set() |
14 root = FilePath('config') | |
1259
672a3d830e7f
arduinoNode: build updates, stats support, etc
drewp <drewp@bigasterisk.com>
parents:
1148
diff
changeset
|
15 print 'reading at %s' % root |
1138 | 16 for f in root.walk(): |
17 if f.isfile() and f.path.endswith('.n3'): | |
18 n3 = f.getContent() | |
19 key = prefix + b'/'.join(f.segmentsFrom(root)) | |
1139
db955e7943af
arduinonode reads config from etcd. use pushConfig.py to inform all nodes
drewp <drewp@bigasterisk.com>
parents:
1138
diff
changeset
|
20 etcd.put(key, n3) |
1138 | 21 written.add(key) |
22 print 'wrote %s' % key | |
23 for k in existing - written: | |
1139
db955e7943af
arduinonode reads config from etcd. use pushConfig.py to inform all nodes
drewp <drewp@bigasterisk.com>
parents:
1138
diff
changeset
|
24 etcd.delete(k) |
1138 | 25 print 'removed %s' % k |
26 | |
1139
db955e7943af
arduinonode reads config from etcd. use pushConfig.py to inform all nodes
drewp <drewp@bigasterisk.com>
parents:
1138
diff
changeset
|
27 main() |