Beispiel #1
0
        if len(forec) > 0:
            tomorrow = forec[0]
            tomorrow_text = grep(tomorrow, text_re)
            tomorrow_high = grep(tomorrow, high_re)
            tomorrow_low = grep(tomorrow, low_re)
        if len(forec) > 1:
            next_day = forec[1]
            next_day_text = grep(next_day, text_re)
            next_day_high = grep(next_day, high_re)
            next_day_low = grep(next_day, low_re)
    
    print "yahoo code: ", code
    return {'code':Code.get_or_none(code=code),
            'sunrise':sunrise,
            'sunset':sunset,
            'temp':temp,
            'text':text,
            'tomorrow_text':tomorrow_text,
            'tomorrow_high':tomorrow_high,
            'tomorrow_low':tomorrow_low,
            'next_day_text':next_day_text,
            'next_day_high':next_day_high,
            'next_day_low':next_day_low,
            }

if __name__ == "__main__":
    #for weatherized in Weatherized.objects.all():
    #    weatherize(weatherized=weatherized)
    weatherize(weatherized=Weatherized.get_or_none(user__twitter_username='******'))
    print "SUCCESS"
Beispiel #2
0
    return {'code':Code.get_or_none(code=code),
            'sunrise':sunrise,
            'sunset':sunset,
            'temp':temp,
            'text':text,
            'tomorrow_text':tomorrow_text,
            'tomorrow_high':tomorrow_high,
            'tomorrow_low':tomorrow_low,
            'next_day_text':next_day_text,
            'next_day_high':next_day_high,
            'next_day_low':next_day_low,
            }

if __name__ == "__main__":
    if settings.DJANGO_SERVER:
        weatherize(weatherized=Weatherized.get_or_none(user__twitter_username='******'))
    else:
        print "hello"
        if True:
            for w in Weatherized.objects.all():
                code = None
                success = False
                msg = ''
                w.weatherized_background = None
                try:
                    code, success = weatherize(weatherized=w)
                except ZipcodeLookupFailedException:
                    msg = 'Could not find weather condition for this zipcode. (Expanded weather lookup coming soon)'
                except WeatherLookupFailedException:
                    msg = 'Weather condition lookup failed inexplicably. (Expanded weather lookup coming soon)'
                except UpdateBackgroundFailedException: