Ejemplo n.º 1
0
 def get(self, which):
     self.set_header("Content-Type", "text/plain")
     self.write(hexFromRgb(self.settings.brites[int(which)]))
Ejemplo n.º 2
0
    """takes 10-bit r,g,b

    returns even if the server is down
    """
    log.debug("setColor(%r,%r)", lightName, rgb)
    if lightName == "bedroomBall":
        try:
            r = _req(method="PUT", url=lightResource["slash-zwave"], body="%g" % (rgb[0] / 1024), headers={})
            return r
        except Exception, e:
            log.warn(e)
            return

    serv = lightResource[lightName]
    try:
        h = hexFromRgb(rgb)
        log.debug("put %r to %r", h, serv)
        r = _req(method="PUT", url=serv, body=h, headers={"content-type": "text/plain"})
        return r
    except Exception, e:
        log.warn("Talking to: %r" % serv)
        log.warn(e)
        return None


def setColorAsync(lightName, rgb):
    """
    uses twisted http, return deferred or sometimes None when there
    was a warning
    """
Ejemplo n.º 3
0
 def get(self, pos):
     self.set_header("Content-Type", "text/plain")
     self.write(hexFromRgb(self.settings.colors[int(pos)]))
Ejemplo n.º 4
0
    """
    log.debug("setColor(%r,%r)", lightName, rgb)
    if lightName == 'bedroomBall':
        try:
            r = _req(method='PUT',
                     url=lightResource['slash-zwave'],
                     body="%g" % (rgb[0] / 1024),
                     headers={})
            return r
        except Exception, e:
            log.warn(e)
            return

    serv = lightResource[lightName]
    try:
        h = hexFromRgb(rgb)
        log.debug("put %r to %r", h, serv)
        r = _req(method='PUT',
                 url=serv,
                 body=h,
                 headers={"content-type": "text/plain"})
        return r
    except Exception, e:
        log.warn("Talking to: %r" % serv)
        log.warn(e)
        return None


def setColorAsync(lightName, rgb):
    """
    uses twisted http, return deferred or sometimes None when there