From 7d1ac56eaea7b9a116f1eb010d228c354f42d18c Mon Sep 17 00:00:00 2001 From: obma Date: Mon, 5 Oct 2015 20:19:14 +0200 Subject: [PATCH 1/4] p: updating openweather_: replaced fgrep, tr, cut with expr Use expr to extract values and names from the OpenWeather API xml instead of the - when using a city with spaces in its name not correctly working - fgrep | tr | cut construct. --- plugins/weather/openweather_ | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) mode change 100644 => 100755 plugins/weather/openweather_ diff --git a/plugins/weather/openweather_ b/plugins/weather/openweather_ old mode 100644 new mode 100755 index bbd3c7a4..a7eea886 --- a/plugins/weather/openweather_ +++ b/plugins/weather/openweather_ @@ -19,15 +19,13 @@ # env.apikey XYZ query_string=$(printf '%s' "${0#*_}" | tr '_' '=') -TMPFILE=$(mktemp) -trap 'rm -f $TMPFILE' EXIT +OWAPI=$( curl -s "http://api.openweathermap.org/data/2.5/weather?mode=xml&${query_string}") # API returns temp in K, we have to convert it in C +# &units=metric would change that ;-) KELVIN_BIAS=273 -curl -s "http://api.openweathermap.org/data/2.5/weather?mode=xml&${query_string}&APPID=${apikey}" > $TMPFILE - -CITY=$(fgrep " Date: Wed, 7 Oct 2015 17:09:44 +0200 Subject: [PATCH 2/4] p: fix openweather_: set correct name for multigraphs Set 'plugin_name' with 'basename $0' and use this variable instead of $0 to avoid having the full path as name for the multigraphs. --- plugins/weather/openweather_ | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/plugins/weather/openweather_ b/plugins/weather/openweather_ index a7eea886..be62596c 100755 --- a/plugins/weather/openweather_ +++ b/plugins/weather/openweather_ @@ -19,6 +19,7 @@ # env.apikey XYZ query_string=$(printf '%s' "${0#*_}" | tr '_' '=') +plugin_name=$( basename $0 ) OWAPI=$( curl -s "http://api.openweathermap.org/data/2.5/weather?mode=xml&${query_string}") # API returns temp in K, we have to convert it in C @@ -30,7 +31,7 @@ CITY=$( expr "$OWAPI" : '.*\ Date: Wed, 7 Oct 2015 18:15:30 +0200 Subject: [PATCH 3/4] p: fix openweather_: returned .label instead of .value for wind direction --- plugins/weather/openweather_ | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/weather/openweather_ b/plugins/weather/openweather_ index be62596c..fe66a3fe 100755 --- a/plugins/weather/openweather_ +++ b/plugins/weather/openweather_ @@ -113,7 +113,7 @@ cat <<- EOF speed.value $WD_SPEED multigraph $plugin_name.wind_direction - direction.label $WD_DIREC + direction.vaule $WD_DIREC EOF From ef061fdd9ed41f42cbda69d777d8bf91b7343915 Mon Sep 17 00:00:00 2001 From: obma Date: Sat, 7 Nov 2015 17:41:55 +0100 Subject: [PATCH 4/4] p: openweather_: typo --- plugins/weather/openweather_ | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/weather/openweather_ b/plugins/weather/openweather_ index fe66a3fe..0a045607 100755 --- a/plugins/weather/openweather_ +++ b/plugins/weather/openweather_ @@ -113,7 +113,7 @@ cat <<- EOF speed.value $WD_SPEED multigraph $plugin_name.wind_direction - direction.vaule $WD_DIREC + direction.value $WD_DIREC EOF