Exemplo n.º 1
0
        log.debug("Found %i devices" % len(devs))

        data = ""
        for dev, ds in mapping.items():
            devnum = int(dev)
            if devnum > (len(devs) - 1) or not devs[devnum]:
                log.error("Device #%i not found!" % devnum)
            else:
                temp = devs[devnum].get_temperature(cfg["units"])
                log.info("Device #%i: %0.1f" % (devnum, temp))
                data = data + string.join([str(ds), str(temp)], ",") + "\r\n"
    except Exception, ex:
        log.error("Error reading data from temper: %s" % ex)
        sys.exit(100)

    try:
        if not debug_mode:
            log.info("Updating feed %s" % cfg["feed"])
            cosm.update_feed(cfg["feed"], cfg["key"], data)
        else:
            log.debug(data)
    except Exception, ex:
        log.error("Error sending to COSM: %s" % ex)
        sys.exit(102)

    log.debug("Done")


if __name__ == '__main__':
    main()
Exemplo n.º 2
0
    for fname,fds in fields.items():
        if allvars.has_key(fname):
            ds = str(fds["datastream"])
            if fds.has_key("mapping"):
                rv = str(allvars[fname])
                if fds["mapping"].has_key(rv):
                    v = str(fds["mapping"][rv])
                else:
                    log.error("Unknown value '%s' for mapped field '%s" % (rv,fname))
                    continue
            else:
                v= str(allvars[fname])
            data = data + string.join([ds,v],",")+"\r\n"
        else:
            log.warning("Field '%s' not found!", fname)
    try:
        if not debug_mode:
            log.info("Updating feed %s" % cfg["feed"])
            cosm.update_feed(cfg["feed"],cfg["key"],data)
        else:
            log.debug(data)
    except Exception, ex:
        log.error("Error sending to COSM: %s" % ex )
        sys.exit(102)
            
    log.debug("Done")


if __name__ == '__main__':
    main()
        data = ""
        try:
            for chip in sensors.iter_detected_chips():
                for cname,cconf in chips.items():
                    if chip.match(Chip(cname)):
                        for feature in chip:
                            if cconf.has_key(feature.label):
                                log.debug('%d:  %s: %.2f' % (cconf[feature.label], feature.label, feature.get_value()))
                                data = data + string.join([str(cconf[feature.label]), str(feature.get_value())],",")+"\r\n"
        except Exception, ex:
            log.error("Error reading sensor values: %s" % ex )
            sys.exit(101)
            
        try:
            if not debug_mode:
                log.info("Updating feed %s" % feed)
                cosm.update_feed(feed,key,data)
            else:
                log.debug(data)
        except Exception, ex:
            log.error("Error sending to COSM: %s" % ex )
            sys.exit(102)
            
    finally:
             sensors.cleanup()
    log.debug("Done")


if __name__ == '__main__':
    main()