Command Line Weather Forecasting Tool

Sanjay Ragavendar
4 min readJun 25, 2023

--

whoami

Hey there! I’m Sanjay Ragavendar , a passionate computer enthusiast with a deep love for all things related to cybersecurity, particularly on the offensive side. My journey in the world of computers has been an exciting one, fueled by an insatiable curiosity and a drive to protect digital systems from potential threats.

Currently, my main focus revolves around web security. I find the intricacies of securing websites and applications fascinating, constantly seeking to understand vulnerabilities and the best ways to defend against them. Through dedicated learning and hands-on experience, I am steadily sharpening my skills in this ever-evolving field.

reaper@kali[~]$ nmap -sC -A -p49563 127.0.0.1

This port is about me and 2 mates(Harish Ravishankar and Laakshit)attending Fastest Coder First Hackthon which was conducted by Microsoft Azure powered by Github-copilot. In the hackathon day we were given a total of 5 problem statements each featuring a programming language. We need to submit the working model within a time limit of 6 hours with a innovation added to it.

Python’ — Weather Forecasting Tool in command line

JavaScript’ — Presonal Finance Tracker

Java’ — Simple E-commerce inventory management system

Ruby’ — Url Shortening Service

.NET’ — Task Management Application

Building of the Tool:

We choose to use Python because 2 in the team were so comfortable with python. So we choose to do it.

We used OpenWeather API to the get the weather forecast from the OpenWeather Site Since it was accurate when compared to other weather forecasting sites. We had to wait for 2 hours to get the API approved and working. After waiting for a 2 Long hours for the API in a sophosticated time of 6 hours we had started to build our code. They have asked to build a weather forecasting tool for searching just cities we had implemented it and also if you enter the latitude and longitude data it will get the accurate results for that specific place.

After another 1 hour of building it I got a idea of using our public IP address to find the latitude and longitude and print the weather forecasting.We have implemented it with the help of ipify.com api to find the public IP address. From the public IP we used another api from freegeoip.app to get the latitude and longitude of the IP address.

Since we had a lot of feature we had to come up with an idea to use it effectively. So,we had used parser (switches) to make it more like a command line tool as well to utilize all the features in the tools we had build the following switches with a help menu which is featured below

usage: weather.py [-h] [-lat LATITUDE] [-long LONGITUDE] [-v] [city]

positional arguments:
city Enter the city name

options:
-h, --help show this help message and exit
-lat LATITUDE, --latitude LATITUDE
Enter the latitude
-long LONGITUDE, --longitude LONGITUDE
Enter the longitude
-v, --verbose Verbose mode

Finally we started formatting our output for end user not everyone want all the weather information everyone are not meteorologist so we added another feature to show minute detials in the weather like sunrise sunset wind speed and etc,.

As I told earlier we had a automated feature which get the public IP to the weather forecast we used that in trail and error(Exception Handling) if you giving the required details like just latitude or just longitude not mention any details like latitude, longitude or city it will be executed. Sometimes if you’re in the company wifi you can’t get the accurate results we have handled that error too in the program otherwise if you are using your mobile phone network or house wifi it get the result more accuretly

Usage

Help Screen

reaper@kali[~/weather-tool]$ python weather.py -h

Weather Forecast using city

reaper@kali[~/weather-tool]$ python weather.py chennai
reaper@kali[~/weather-tool]$ python weather.py -c chennai

Weather Forecast using latitude and longitude

reaper@kali[~/weather-tool]$ python weather.py -lat 13.0827 -long 80.2707

Automated Weather Forecast

reaper@kali[~/weather-tool]$ python weather.py
reaper@kali[~/weather-tool]$ python weather.py -lat 13.0827
reaper@kali[~/weather-tool]$ python weather.py -long 80.2707

As I mentioned earlier if there is not enough detials given it will be using automated weather forecast

Screenshots

verbose mode
automated mode

Conclusion:

Because of this hackathon I got connected to many in industry people which help me to learn the current trend and interact with more valuable people I discussed with them how can I improve myself which path to follow. I also got hands-on experience with the github Co-pilot (actually more useful than Chat-GPT after writing the comments for what I needed it was just Tab, Enter and Tab Enter) Since I was new using it I couldn’t use it to its full capacity.

You can check out the project in my github repo and don’t forget follow me in medium I will post my experience I will also start to post about new vulnerabilities in the web security.

Other Links:

Repository: https://github.com/Sanjay-2610/Weather-Forecast-Tool

Linked In: https://www.linkedin.com/in/sanjay-ragavendar/

Github: https://github.com/Sanjay-2610

--

--

Sanjay Ragavendar
Sanjay Ragavendar

Written by Sanjay Ragavendar

Hey Everyone👋 I am Sanjay , a tech enthusiast , a active learner , cyber security learner.

No responses yet