Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
A Python wrapper for Apple's WeatherKit API
You can install the WeatherKit library from PyPI:
$ pip install weatherkit-python
The library is supported on Python 3.6 and above.
The following dependencies are installed with the library:
The library will take care of JWT generation for you since it's such a pain. The expiration time for the token is one hour after generation.
You will need to provide your Developer Team ID, Service ID, Key ID, and Private Key to the library. This is by far the most challenging part, but these sites had instructions that were very helpful:
The library will convert all datetime values to the timezone of your choosing. You can specify UTC
to return GMT datetimes. All values are returned in ISO8106 format.
The Apple WeatherKit APIs only return values in metric units, but the library also adds imperial properties for all values. All temperatures have both Fahrenheit and Celsius properties. See the API docs for all available object properties.
The Apple APIs return conditionCode
values that are automatically mapped to human-readable conditions strings. The available conditions are:
Code | Condition |
---|---|
Clear | Clear |
Cloudy | Cloudy |
Dust | Dust |
Fog | Fog |
Haze | Haze |
MostlyClear | Mostly Clear |
MostlyCloudy | Mostly Cloudy |
PartlyCloudy | Partly Cloudy |
ScatteredThunderstorms | Scattered Thunderstorms |
Smoke | Smoke |
Breezy | Breezy |
Windy | Windy |
Drizzle | Drizzle |
HeavyRain | Heavy Rain |
Rain | Rain |
Showers | Showers |
Flurries | Flurries |
HeavySnow | Heavy Snow |
MixedRainAndSleet | Mixed Rain and Sleet |
MixedRainAndSnow | Mixed Rain and Snow |
MixedRainfall | Mixed Rainfall |
MixedSnowAndSleet | Mixed Snow and Sleet |
ScatteredShowers | Scattered Showers |
ScatteredSnowShowers | Scattered Snow Showers |
Sleet | Sleet |
Snow | Snow |
SnowShowers | Snow Showers |
Blizzard | Blizzard |
BlowingSnow | Blowing Snow |
FreezingDrizzle | Freezing Drizzle |
FreezingRain | Freezing Rain |
Frigid | Frigid |
Hail | Hail |
Hot | Hot |
Hurricane | Hurricane |
IsolatedThunderstorms | Isolated Thunderstorms |
SevereThunderstorm | Severe Thunderstorm |
Thunderstorm | Thunderstorm |
Tornado | Tornado |
TropicalStorm | Tropical Storm |
The DailyForecast
, NextHourForecast
, and HourlyForecast
objects have a precip_type
string that can have the following values:
type | description |
---|---|
hail | A form of precipitation consisting of solid ice] |
mixed | Mixed precipitation |
rain | Rain |
sleet | A form of precipitation consisting of ice pellets |
snow | Snow |
none | No precipitation |
import os
import json
import weatherkit
# Load the credentials from wherever you store them securely
team_id = os.environ.get('APPLE_TEAM_ID')
key_id = os.environ.get('APPLE_KEY_ID')
service_id = os.environ.get('APPLE_SERVICE_ID')
private_key = os.environ.get('APPLE_PRIVATE_KEY')
# Instantiate the WeatherKit object
wk_client = weatherkit.WeatherKit(team_id, service_id, private_key, key_id)
# Include any/all of the datasets we want to pull in the list
datasets = [
'forecastHourly',
'forecastDaily',
'currentWeather',
'forecastNextHour',
]
# Fetch the API
forecasts = wk_client.fetch(datasets, 39.5900, -104.726763, 'US', 'US/Mountain')
# There is a convenience method for converting the forecast response object to JSON
forecasts_json = forecasts.as_json()
From the /weatherkit
directory:
$ python -m unittest tests/tests.py
Pull requests are welcome so long as they do not add unnecessary complexity to the user.
FAQs
A Python interface for Apple's WeatherKit APIs
We found that weatherkit-python demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.