Mercurial > code > home > repos > homeauto
annotate service/arduinoNode/pushConfig.py @ 1188:afd19bf8b499
various docker setups and build fixes
Ignore-this: adb559337fa1bd058818d1fc99d80ac1
darcs-hash:9aa24b30a2d3eab3676b85d2aa686d6ef24b5717
author | drewp <drewp@bigasterisk.com> |
---|---|
date | Fri, 28 Dec 2018 02:13:15 -0800 |
parents | 8b4eda2cf0bd |
children | 12f9f1838fb5 |
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 | |
1139
db955e7943af
arduinonode reads config from etcd. use pushConfig.py to inform all nodes
drewp <drewp@bigasterisk.com>
parents:
1138
diff
changeset
|
7 etcd = etcd3.client(host='bang6') |
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') | |
15 for f in root.walk(): | |
16 if f.isfile() and f.path.endswith('.n3'): | |
17 n3 = f.getContent() | |
18 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
|
19 etcd.put(key, n3) |
1138 | 20 written.add(key) |
21 print 'wrote %s' % key | |
22 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
|
23 etcd.delete(k) |
1138 | 24 print 'removed %s' % k |
25 | |
1139
db955e7943af
arduinonode reads config from etcd. use pushConfig.py to inform all nodes
drewp <drewp@bigasterisk.com>
parents:
1138
diff
changeset
|
26 main() |