add timeout on read to avoid haning on the ssh tunnel

master
doorbuzz 2016-09-05 20:11:17 +02:00
parent de23e91533
commit d30d8bcd2b
2 changed files with 8 additions and 3 deletions

View File

@ -32,14 +32,18 @@ do
done
ocounter="$counter"
echo "peoplecounter" >&"${COPROC[1]}"
read counter <&"${COPROC[0]}"
read -t 1 counter <&"${COPROC[0]}"
if [ $? -ne 0 ]
then
counter=-1
fi
if [ "$counter" != "$ocounter" ]
then
logger $0 peoplecounter=$counter
echo "neocounter=$counter" | ./redi.sh
fi
echo "spacestatus" >&"${COPROC[1]}"
read status <&"${COPROC[0]}"
read -t 1 status <&"${COPROC[0]}"
if ! [ "$status" = "open" ]; then # do nothing if space is closed
continue
else

View File

@ -134,7 +134,8 @@ if __name__ == '__main__':
for j in range(0,60,5):
strip.setPixelColor(clockcalc(j), color)
# put the current people count as magenta
strip.setPixelColor(clockcalc(myredis.get('neocounter')),Color(10,0,10))
if myredis.get('neocounter') >= 0:
strip.setPixelColor(clockcalc(myredis.get('neocounter')),Color(10,0,10))
# put the minute hand as red
strip.setPixelColor(clockcalc(time.strftime('%M',time.localtime())),Color(30,0,0))
# put the seconds hand as green