Example #1
0
def main():
    """ Get geo id for geo location, and request current weather condition.
    Retrieve current temperature and location local time.
    """

    degree = u"\N{DEGREE SIGN}"

    # Geo request
    geo_url = wetteronline.request_url(KEY, UID, lat=LAT, lon=LON)
    wog = wetteronline.load_wetteronline(geo_url)
    print('Geo data: {}'.format(wog.json))
    gid = wog.gid()
    location = wog._wetteronline_data('locationName')

    # Weather request
    weather_url = wetteronline.request_url(KEY, UID, gid=gid)
    wow = wetteronline.load_wetteronline(weather_url)
    date_time = wow._wetteronline_data('local_date', gid=gid)
    temperature = wow._wetteronline_data('tt_C', gid=gid)
    fahrenheit = convert_c2f(temperature)

    print('Date Time: {}'.format(date_time))
    print('Weather data response: {}'.format(wow.json))
    print(u'{}: Current Temperature {}C{}/{:.2f}F'.format(location, temperature,
                                                      degree, fahrenheit))
Example #2
0
def current_for_gids():
    """Collect weather conditions for list of geo id's"""

    # pass list of gids to get data in one request
    # example list: "10518,10513,10400"
    glist = ','.join(make_gid_list(GEO_POSITIONS))

    url = build_request_url(KEY, UID, gid=glist)

    wo_weather = wetteronline.load_wetteronline(url)
    print(wo_weather.json)
Example #3
0
def get_gid(url):
    """Returns geo id for geo api url"""

    return wetteronline.load_wetteronline(url).gid()