view light9/curvecalc/client.py @ 1438:594160be47f1

device control page now saves new effects and can clear itself Ignore-this: 5166c8f19d3e399e15c1189d3c7e5a70
author drewp@bigasterisk.com
date Sat, 11 Jun 2016 21:03:45 +0000
parents c756638275d6
children 7772cc48e016
line wrap: on
line source

"""
client code for talking to curvecalc
"""
import cyclone.httpclient
from light9 import networking
import urllib
from run_local import log

def sendLiveInputPoint(curve, value):
    f = cyclone.httpclient.fetch(
        networking.curveCalc.path('liveInputPoint'),
        method='POST', timeout=1,
        postdata=urllib.urlencode({
            'curve': curve,
            'value': str(value),
        }))
    @f.addCallback
    def cb(result):
        if result.code // 100 != 2:
            raise ValueError("curveCalc said %s: %s", result.code, result.body)
    return f