Mercurial > code > home > repos > homeauto
changeset 1148:8b4eda2cf0bd
fix pushconfig
Ignore-this: 36fd12eb507fbe027b9a00dbd78f13af
darcs-hash:a89764f2ad7791417d7c68d6ba30df92be97fe2c
author | drewp <drewp@bigasterisk.com> |
---|---|
date | Sat, 14 Apr 2018 23:46:54 -0700 |
parents | ef494fe0499f |
children | 163042261ef1 |
files | service/arduinoNode/Dockerfile service/arduinoNode/arduinoNode.py service/arduinoNode/makefile service/arduinoNode/pushConfig.py |
diffstat | 4 files changed, 14 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/service/arduinoNode/Dockerfile Wed Apr 04 14:58:27 2018 -0700 +++ b/service/arduinoNode/Dockerfile Sat Apr 14 23:46:54 2018 -0700 @@ -1,7 +1,7 @@ FROM alpine:3.7 WORKDIR /opt -RUN apk add --no-cache gcc build-base jpeg-dev lapack-dev libffi-dev linux-headers musl-dev openssl-dev py2-cffi py2-numpy py2-numpy-f2py py2-pip python2 python2-dev indent +RUN apk add --no-cache gcc build-base jpeg-dev lapack-dev libffi-dev linux-headers musl-dev openssl-dev py2-cffi py2-numpy py2-numpy-f2py py2-pip python2 python2-dev indent COPY requirements.txt ./ RUN pip download --cache-dir /tmp/pip-cache -r requirements.txt
--- a/service/arduinoNode/arduinoNode.py Wed Apr 04 14:58:27 2018 -0700 +++ b/service/arduinoNode/arduinoNode.py Sat Apr 14 23:46:54 2018 -0700 @@ -54,7 +54,6 @@ self.boards = [] self.reread() - self.rereadLater = None deferToThread(self.watchEtcd) def watchEtcd(self): @@ -65,12 +64,16 @@ reactor.callFromThread(self.configChanged) def configChanged(self): - if self.rereadLater: - self.rereadLater.cancel() + self.cancelRead() self.rereadLater = reactor.callLater(.1, self.reread) + def cancelRead(self): + if getattr(self, 'rereadLater', None): + self.rereadLater.cancel() + self.rereadLater = None + def reread(self): - self.rereadLater = None + self.cancelRead() log.info('read config') self.configGraph = ConjunctiveGraph() for v, md in etcd.get_prefix(self.etcPrefix):
--- a/service/arduinoNode/makefile Wed Apr 04 14:58:27 2018 -0700 +++ b/service/arduinoNode/makefile Sat Apr 14 23:46:54 2018 -0700 @@ -8,3 +8,6 @@ local_run: docker run -it -p 9059:9059 --device=/dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A900cepU-if00-port0 --net=host bang6:5000/arduino_node python ./arduinoNode.py -v + +push_config: + bin/python pushConfig.py arduino/
--- a/service/arduinoNode/pushConfig.py Wed Apr 04 14:58:27 2018 -0700 +++ b/service/arduinoNode/pushConfig.py Sat Apr 14 23:46:54 2018 -0700 @@ -1,13 +1,14 @@ from __future__ import division - +import sys import etcd3 from twisted.python.filepath import FilePath etcd = etcd3.client(host='bang6') +prefix, = sys.argv[1:] + def main(): - prefix = b'arduino/' existing = set(md.key for v, md in etcd.get_prefix(prefix)) written = set() root = FilePath('config')