# HG changeset patch # User drewp # Date 1523774814 25200 # Node ID 8b4eda2cf0bd30bd9234cd93d2d8f971582d8eb2 # Parent ef494fe0499f332af06eb96d59b418ec2b2e265e fix pushconfig Ignore-this: 36fd12eb507fbe027b9a00dbd78f13af darcs-hash:a89764f2ad7791417d7c68d6ba30df92be97fe2c diff -r ef494fe0499f -r 8b4eda2cf0bd service/arduinoNode/Dockerfile --- 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 diff -r ef494fe0499f -r 8b4eda2cf0bd service/arduinoNode/arduinoNode.py --- 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): diff -r ef494fe0499f -r 8b4eda2cf0bd service/arduinoNode/makefile --- 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/ diff -r ef494fe0499f -r 8b4eda2cf0bd service/arduinoNode/pushConfig.py --- 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')