def get_weather():
  print('=' * 20)
  try:
    w, f = wa.pick_your_weather()
  except requests.ConnectionError or ValueError:
    print('=' * 20)
    sys.exit('Weather servers are busy. Try again in a few minutes...')

  # Call functions in WeatherAnywhere.py to retrieve weather data
  weather = wa.get_current_weather(w)
  forecast = wa.get_forecast(w,f)
  fmt = '{}\n\nWeather information provided by api.wunderground.com'
  forecast = fmt.format(forecast)
  return w, f, weather, forecast
def get_weather():
    print('=' * 20)
    try:
        w, f = wa.pick_your_weather()
    except requests.ConnectionError or ValueError:
        print('=' * 20)
        sys.exit('Weather servers are busy. Try again in a few minutes...')

    # Call functions in WeatherAnywhere.py to retrieve weather data
    weather = wa.get_current_weather(w, f)
    forecast = wa.get_forecast(w, f)
    fmt = '{}\n\nWeather information provided by api.wunderground.com'
    forecast = fmt.format(forecast)
    return w, f, weather, forecast
Exemplo n.º 3
0
def get_background_color(day):
  color = {1: [.5,.5,.5],  # Medium grey
           2: [.5,0,.5],   # Purple
           3: [.75,0,0],   # Light red
           4: [.5,0,0],    # Medium red
           5: [0,.5,.5],   # Medium green
           6: [1,.5,0],    # Orange
           7: [.25,.25,1]} # Light blue

  # Monday is 1, Sunday is 7
  r,g,b = color[day]
  return r,g,b

print('=' * 20)
try:
  w,f = wa.pick_your_weather()
except requests.ConnectionError or ValueError:
  print('=' * 20)
  sys.exit('Weather servers are busy. Try again in a few minutes...')

weather_now = get_weather_now(w)
forecast = get_forecast(f)
icon_path = './icons/'
weather_icons = get_icons(w,f, icon_path)

# Loop list of needed icons
for icon in weather_icons:
  # Check if we have them
  if os.path.exists(icon):
    continue
  # If missing then download what