O.weather is a simple Python script that allows you to fetch real-time weather information and display it either as an ASCII table or in plain text format. It uses the OpenWeatherMap API to retrieve weather data.
- Fetches and displays current weather conditions, including status, humidity, sunrise and sunset times, wind speed, and temperatures.
- Provides a detailed weather forecast for the upcoming day at the time you specify.
Before you begin, make sure you have the following installed:
- Python 3.x
- The
pyowm
library
You can install the pyowm
library using the following command:
pip install pyowm
- Clone this repository to your local machine or download the ZIP file and extract it.
- Navigate to the project directory:
cd O.weather/
- Open the
o.weather.py
file in your preferred text editor. - Customize the values of the following variables according to your preferences:
-
CITY
: Replace this variable with the name of the city for which you want to obtain weather information. -
API_KEY
: Replace this variable with your OpenWeatherMap API key. You can obtain an API key by signing up at OpenWeatherMap (free registration available). -
HOURS_TO_ADD
: Set the number of hours to add to the current time to get weather forecasts for the desired time. -
HOURS_TO_ADD_TWO
: Set the number of hours to add to the current time to get weather forecasts for another desired time. -
UNITS
: Choose between 'celsius' or 'fahrenheit' for your preferred temperature unit. -
LANG
: Choose the language in which you want to receive weather information (e.g., 'EN' for English).
To use the script, you need to execute o.weather.py
using Python. Here's how it works:
python3 o.weather.py
The script supports the following command-line options:
-
-a
or--ascii
: Use this option to generate a weather report in ASCII table format. -
-v
or--version
: Use this option to display the script's version number.
The script operates by following these steps:
-
It retrieves the current time.
-
It uses the OpenWeatherMap API to obtain current weather information for the configured city.
-
It adjusts the current time by adding the number of hours specified in
HOURS_TO_ADD
andHOURS_TO_ADD_TWO
to obtain two future moments. -
It fetches weather forecasts for these two future moments using the OpenWeatherMap API.
-
It then displays the weather information either as an ASCII table or in plain text format, depending on the command-line options.
- Display a weather report in plain text format for the configured city:
python3 o.weather.py
- Generate a weather report in ASCII table format for the configured city:
python3 o.weather.py -a
- Display the script's version:
python3 o.weather.py -v
This software is provided to you free of charge, with the hope that if you find it valuable, you'll consider making a donation to a charitable organization of your choice :
-
SPA (Society for the Protection of Animals): The SPA is one of the oldest and most recognized organizations in France for the protection of domestic animals. It provides shelters, veterinary care, and works towards responsible adoption.
-
French Popular Aid: This organization aims to fight against poverty and exclusion by providing food aid, clothing, and organizing recreational activities for disadvantaged individuals.
-
Doctors Without Borders (MSF): MSF provides emergency medical assistance to populations in danger around the world, particularly in conflict zones and humanitarian crises.
-
Restaurants of the Heart : Restaurants of the Heart provides meals, emergency accommodation, and social services to the underprivileged.
-
French Red Cross: The Red Cross offers humanitarian aid, emergency relief, first aid training, as well as social and medical activities for vulnerable individuals.
Every small gesture matters and contributes to making a real difference.
For support email :