view service/arduinoNode/pushConfig.py @ 1305:965397a2648a

rm old complicated usb bus checker and resetter that caught some error modes and reset the right parts of the usb tree Ignore-this: 1003481c29f8bb01b3758bf6f6241d65 darcs-hash:78af0ceedceca9a96255b825a26003a75f6b5991
author drewp <drewp@bigasterisk.com>
date Sun, 21 Apr 2019 03:04:42 -0700
parents 672a3d830e7f
children 048a8df60e2e
line wrap: on
line source

from __future__ import division
import sys
import etcd3

from twisted.python.filepath import FilePath

etcd = etcd3.client(host='bang6', port=9022)

prefix, = sys.argv[1:]

def main():
    existing = set(md.key for v, md in etcd.get_prefix(prefix))
    written = set()
    root = FilePath('config')
    print 'reading at %s' % root
    for f in root.walk():
        if f.isfile() and f.path.endswith('.n3'):
            n3 = f.getContent()
            key = prefix + b'/'.join(f.segmentsFrom(root))
            etcd.put(key, n3)
            written.add(key)
            print 'wrote %s' % key
    for k in existing - written:
        etcd.delete(k)
        print 'removed %s' % k

main()