After spending some time playing around with BPQ, I have learned how powerful its applications interface is. I first followed a guide to create a system info application, allowing for checking system resources from afar. Today, I set out to create a weather application that allows the user to check their local (to the zip code) weather over packet.
Get the wx.py script at GitHub.
The script is written in Python, and is fairly simple. It only requires one module installation: requests, which is used for retrieving the JSON data from Openweathermap. This script requests the user’s zip code, and returns values such as:
- Current temperature
- “Feels like” temperature
- Barometric pressure
- Humidity
- Wind speed, direction, gust speed
- Textual description of the weather.
- Rainfall amounts in the past 1, and past 3 hours
- Snowfall amounts in the past 1 and past 3 hours
All you’ve got to do to run it is request an API key from Openweathermap, install the requests module via pip install requests
, create the configuration file which simply consists of your API key, and run it. Running the program on its own for the first time instructions you how to create the configuration file, but it simply contains the following:
[DEFAULT]
api_key=YOURAPIKEY
Replace YOURAPIKEY with whichever key you’re assigned by Openweathermap.
If running it plainly, and not through BPQ, you’ll see a blank screen. This is because of a line in the code that waits for BPQ to send the user’s call, call = input()
. This is done to capture the call string that is sent by BPQ by default to applications run through its application interface. Press enter at this blank screen and you’ll be prompted to enter the zip code for which you’d like to request the weather report.
In order to set the application up to run through BPQ, follow this guide. In my configuration, the entry in bpq32.cfg looks like:
APPLICATION 6,WX, C 2 HOST 2 S
When users connect to my node, they will see the “WX” option and are able to access it through that.
Please note that, after cloning the script from GitHub, you must make it executable. In Linux, this is accomplished by running the command chmod +x wx.py
. If you don’t do this, it will not run when executed from BPQ.
Leave a Reply