DhillanC / github_template_1

This repository contains Dhillan's lab for agile planning
0 stars 0 forks source link

Get weather report #9

Open DhillanC opened 3 months ago

DhillanC commented 3 months ago

As a User I need To get the weather report So that I modify the plans

Details and Assumptions

Extract from a possible linux script:

!/bin/bash

Assign today's weather filename

today=$(date +%Y%m%d) weather_report=rawdata$today

Download today's weather raw data

city=Casablanca curl wttr.in/$city --output $weather_report

Save today's temperature

grep °C $weather_report > temperatures.txt obs_tmp=$(head -1 temperatures.txt | tr -s " " | xargs | rev | cut -d " " -f2 | rev)

Save tomorrow's temperature

fc_temp=$(head -3 temperatures.txt | tail -1 | tr -s " " | xargs | cut -d "C" -f2 | rev | cut -d " " -f2 | rev)

Store current date to variables for future validation

TZ='Africa/Casablanca'

hour=$(TZ='Morocco/Casablanca' date -u +%H) day=$(TZ='Morocco/Casablanca' date -u +%d) month=$(TZ='Morocco/Casablanca' date +%m) year=$(TZ='Morocco/Casablanca' date +%Y)

Append the fields of the execution time with the observed temperature

record=$(echo -e "$year\t$month\t$day\t$hour\t$obs_tmp\t$fc_temp") echo $record>>rx_poc.log

Acceptance Criteria

 Given [some context]
 When [certain action is taken]
 Then [the outcome of action is observed]
DhillanC commented 3 months ago

Corrected shell script:

!/bin/bash

Assign today's weather filename

today=$(date +%Y%m%d) weather_report=rawdata$today

Download today's weather raw data

city=Casablanca curl wttr.in/$city --output $weather_report

extract all lines containing temperatures from the weather report and write to file

grep °C $weather_report > temperatures.txt

Save today's temperature

obs_tmp=$(head -1 temperatures.txt | tr -s " " | xargs | rev | cut -d " " -f2 | rev)

Save tomorrow's forecast temperature

fc_temp=$(head -3 temperatures.txt | tail -1 | tr -s " " | xargs | cut -d "C" -f2 | rev | cut -d " " -f2 | rev)

Use command substitution to store the current day, month, and year in corresponding shell variables for future validation

TZ='Africa/Casablanca'

hour=$(TZ='Morocco/Casablanca' date -u +%H) day=$(TZ='Morocco/Casablanca' date -u +%d) month=$(TZ='Morocco/Casablanca' date +%m) year=$(TZ='Morocco/Casablanca' date +%Y)

create a tab-delimited record

recall the header was created as follows:

header=$(echo -e "year\tmonth\tday\thour_UTC\tobs_tmp\tfc_temp")

echo $header>rx_poc.log

Append the fields of the execution time with the observed temperature

record=$(echo -e "$year\t$month\t$day\t$hour\t$obs_tmp\t$fc_temp") echo $record>>rx_poc.log

Scheduling crontab

Local time is GMT-4 , Casablanca timezone is UTC+1

We should schedule the job at 7am in order to run it at 12:00 Casablanca TZ

m h dom mon dow command

0 7 * /home/project/rx_poc.sh