weatherCLI is a Linux command line UI based application that shows the user the weather and sun information from the National Weather Service written in Python. Because of this, weatherCLI is only available in the United States, and its territories, However, the sun calculation is worldwide.
https://www.noaa.gov/
https://weather.gov/
https://aa.usno.navy.mil/data/api
https://aa.usno.navy.mil/api/
https://nominatim.openstreetmap.org/
https://openstreetmap.org/copyright
Human readable worded weather from NOAA's API (example: Partly cloudy, with a low around 32. West wind 5 to 14 mph):
- Both day and night are unique
- Up to one week forecast
Graphs:
- Precipitation type & Probability
- Daily low
- Daily high
Sun data:
- Sunrise
- Sunset
- Solar noon
- Moon info
Live data from the location’s nearest weather station:
- Temperature
- Humidity
- Visibility
- Dew point
- Name of station
- Wind direction
- Sustained wind speed
- Wind gusts (will show NA knots if no gusts)
- Local station url if you want to get more information:
weather warnings (example: Frost Advisory, Winter Storm Warning or Severe Thunderstorm Warning)
The National Weather Service allows you to generate XML files showing weather data from a specific longitude and latitude. This program reads those XML files and presents them to the user as readable data. To get the sun positions, the program uses the US Navy's API for getting sun info expressed in json, and prints the result out on terminal.
OS | Supported? |
---|---|
Debian | ✅ |
Ubuntu | ✅ |
Fedora | ✅ |
Arch | ✅ |
Mint | 🔶 |
Pop OS | 🔶 |
EndeavourOS | 🔶 |
Windows | ❌ |
✅: Supported
🔶: Untested
❌: Broken
Can be installed from almost all package managers:
Debian/Ubuntu/Mint:
sudo apt install wget
Arch:
pacman -S wget
Fedora
sudo dnf install wget
*may already be installed
wget https://raw.githubusercontent.com/beee33/weatherCLI/main/installer.sh
sudo sh installer.sh
Follow Build from source instructuions until the end of step 4
python3 main.py
Instructions to install git are on: Git's website however you can just use:
Debian/Ubuntu/Mint:
sudo apt install git
Fedora
sudo dnf install git
git clone "https://github.com/beee33/weatherCLI"
cd weatherCLI
Create new virtual enviroment using python's venv
python3 -m venv <name>
Enter venv
source <name>/bin/activate
*Note: if venv works, your shell should have (<name>) in prompt Install dependencys
python3 -m pip install -r requirements.txt
❗ some Operating Systems eg: Debian, dont like you to install packages in the default python environment, as it may override system packages that are needed. I have bricked a VM by doing this.
Install dependencys
python3 -m pip install -r requirements.txt
pip install pyinstaller
or
python3 -m pip install pyinstaller
*Note, you may have to use a virtual enviroment for some systems. You can use something like pyenv to create instances of python with diffrent versions: https://github.com/pyenv/pyenv
For this program I would reccomend using python 3.10, as that is what version this program is written for. If not, try to rename all instances of it to your python version
This adds the new venv site packages path to pyinstaller, so it can use it. You should replace python3.10 with your python version eg python3.11
pyinstaller main.py --onefile --paths "<name>/lib/python3.10/site-packages"
Leave virtual enviroment
deactivate
pyinstaller main.py --onefile
sudo cp dist/main /usr/bin/weatherCLI
sudo chmod 755 /usr/bin/weatherCLI
sudo mkdir /etc/weatherCLI
sudo chmod 777 -R /etc/weatherCLI
*note this directory and its subdirectorys is intended to be accessible for all users
sudo chmod 711 -R /etc/weatherCLI
if you get the error: "[PYI-1890462:ERROR] Failed to load Python shared library '/tmp/_MEIWYQO9N/libpython3.10.so': dlopen: /tmp/_MEIWYQO9N/libpython3.10.so: cannot open shared object file: No such file or directory"
This command fixes that so pyinstaller knows python's path. This should be replaced with your python version and the temp directory may be diffrent, I was using python 3.10.
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/python3.10
install dependencies
pip install pipreqs
run pipreqs, after executing, it will generate a reqirements.txt file in your project directory
*Note: --scan-notebooks I am running this in a Jupyter Notebook, so the program will scan for files there, you can remove this if you are not using Jupyter Notebooks.
*Note: --force, Use this to override previous reqirements.txt files, you dont need this if you are not overriding any files.
pipreqs <project directory> --force --scan-notebooks
Test if it works, by following steps: 3 4a/4b:
If you get bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: xml. Do you need to install a parser library? error.
This is because the reqirements.txt file misses a required library that BeautfulSoup uses. Add missing library.
echo "lxml==5.3.1" >> requirements.txt
WeathterCLI uses OpenStreetMaps’s geocoding API to get latitude and longitude positions from user input. It converts the latitude and longitude into a url that has the XML data. This url is stored in “/etc/weatherCLI/<towns/zipcode/places>/<queryname>/url.txt” an example is: “/etc/weatherCLI/towns/Boston\ MA/url.txt”. The data for the sun positions are only calculated once per day per location, and the output is put in a file so that the user doesn't have to recalculate the same sun data for each day. All of the urls and sun data is stored in “/etc/weatherCLI/”
weatherCLI "city:Boston MA" -t most -s
weatherCLI "poi:Rochester Institute of Technology" -t most
weatherCLI "zip:10001" -t most -s
weatherCLI "city:Palm Beach FL" -t all -s
weatherCLI "city:Seattle WA" -t24 -t onlysun
weatherCLI "city:Salt Lake City UT" -t onlyworded