コード例 #1
0
ファイル: Wunderground.py プロジェクト: navillacorta/parLED
def main():
    Strip = SerialRGB("/dev/ttyUSB0", baud=115200)

    FirstRun = True
    lastUpdated = datetime.now()

    try:
        while 1:
            if ((datetime.now() - lastUpdated).seconds
                    == INTERVAL) or (FirstRun):
                data = getCurrentWeather()
                if isinstance(data, Obj.ObjectifiedElement):
                    print ET.tostring(data,
                                      pretty_print=1,
                                      xml_declaration=1,
                                      encoding="utf-8")
                    temp = farenheit2rgb(
                        float(data.current_observation.temp_f.text))
                    Strip.cross_fade(temp)
                    lastUpdated = datetime.now()
                    if FirstRun:
                        FirstRun = False
                else:
                    print "Failed to parse data. Time:", datetime.now()
                    continue
                time.sleep(2)
    except KeyboardInterrupt:
        print "Aborting!"
        sys.exit(1)
    except Exception, e:
        import traceback
        traceback.print_exc()
コード例 #2
0
ファイル: Wunderground.py プロジェクト: navillacorta/parLED
def main():
    Strip = SerialRGB("/dev/ttyUSB0", baud=115200)
    
    FirstRun = True
    lastUpdated = datetime.now()
    
    try:
        while 1:
            if ((datetime.now() - lastUpdated).seconds == INTERVAL) or (FirstRun):
                data = getCurrentWeather()
                if  isinstance(data, Obj.ObjectifiedElement):
                    print ET.tostring(data, pretty_print=1, xml_declaration=1, encoding="utf-8")
                    temp = farenheit2rgb(float(data.current_observation.temp_f.text))
                    Strip.cross_fade(temp)
                    lastUpdated = datetime.now()
                    if FirstRun:
                        FirstRun = False
                else:
                    print "Failed to parse data. Time:", datetime.now()
                    continue
                time.sleep(2)
    except KeyboardInterrupt:
        print "Aborting!"
        sys.exit(1)
    except Exception, e:
        import traceback
        traceback.print_exc()
コード例 #3
0
        return None


if __name__ == "__main__":
    Strip = SerialRGB("/dev/ttyUSB0", baud=115200)
    
    FirstRun = True
    lastUpdated = datetime.now()
    
    try:
        while 1:
            if ((datetime.now() - lastUpdated).seconds == INTERVAL) or (FirstRun):
                data = getCurrentWeather()
                if  isinstance(data, Obj.ObjectifiedElement):
                    print ET.tostring(data, pretty_print=1, xml_declaration=1, encoding="utf-8")
                    temp = farenheit2rgb(float(data.temperature.attrib["value"]))
                    Strip.cross_fade(temp)
                    lastUpdated = datetime.now()
                    if FirstRun:
                        FirstRun = False
                else:
                    print "Failed to parse data. Time:", datetime.now()
                    continue
                time.sleep(2)
    except KeyboardInterrupt:
        print "Aborting!"
        sys.exit(1)
    except Exception, e:
        import traceback
        traceback.print_exc()