new version, new tarball, bug fix for weather

This commit is contained in:
inxi-svn 2013-05-18 04:11:18 +00:00
parent dc2fd3aa53
commit 76dc2733b8
2 changed files with 29 additions and 13 deletions

28
inxi
View file

@ -1,7 +1,7 @@
#!/usr/bin/env bash
########################################################################
#### Script Name: inxi
#### Version: 1.9.01
#### Version: 1.9.02
#### Date: May 17 2013
#### Patch Number: 00
########################################################################
@ -7969,7 +7969,9 @@ get_weather_data()
local location_site='http://geoip.ubuntu.com/lookup'
local weather_feed='http://api.wunderground.com/auto/wui/geo/WXCurrentObXML/index.xml?query='
local weather_spider='http://wunderground.com/'
local data_grab_error='' wget_error=0 b_testing=false b_debug=false
local data_grab_error='' wget_error=0
local b_test_loc=true b_test_weather=false b_debug=false
local test_location='location2.xml' test_weather='weather-feed.xml'
local location_data='' location='' weather_data='' location_array_value='' a_location=''
local weather_array_value='' site_elevation=''
local testDir="$HOME/bin/scripts/inxi/data/weather/"
@ -7979,7 +7981,7 @@ get_weather_data()
if [[ -n $ALTERNATE_WEATHER_LOCATION ]];then
location=$ALTERNATE_WEATHER_LOCATION
else
if [[ $b_testing != 'true' ]];then
if [[ $b_test_loc != 'true' ]];then
# make sure location site is up
wget -q -t 1 -T 5 --spider $location_site || wget_error=$?
# grab the location xml file
@ -7992,20 +7994,21 @@ get_weather_data()
data_grab_error="Error: location server up but download error - wget: $wget_error"
fi
else
if [[ -f $testDir/my-location.xml ]];then
location_data="$( cat $testDir/my-location.xml)"
if [[ -f $testDir$test_location ]];then
location_data="$( cat $testDir$test_location )"
else
data_grab_error="Error: location xml local file not found."
fi
fi
if [[ -z $( grep -i '<?xml' <<< $location_data ) ]];then
data_grab_error="Error: location downloaded but data contains no <?xml statement."
if [[ -z $( grep -i '<Response' <<< $location_data ) ]];then
data_grab_error="Error: location downloaded but data contains no xml."
else
# clean up xml and make easy to process with newlines, note, bsd sed has no support for inserting
# \n dircctly so we have to use this hack
# location_data="$( sed $SED_RX 's|><|>\n<|g' <<< $location_data )"
location_data="$( sed $SED_RX 's|><|>\
<|g' <<< $location_data )"
# echo -e "ld:\n$location_data"
location_array_value=$( gawk '
function clean(data) {
returnData=""
@ -8086,7 +8089,7 @@ get_weather_data()
fi
fi
if [[ $b_debug == 'true' ]];then
echo "${A_WEATHER_DATA[0]}"
echo -e "location array:\n${A_WEATHER_DATA[0]}"
echo "location: $location"
fi
@ -8098,7 +8101,7 @@ get_weather_data()
if [[ -n $data_grab_error ]];then
A_WEATHER_DATA=$data_grab_error
else
if [[ $b_testing != 'true' ]];then
if [[ $b_test_weather != 'true' ]];then
wget -q -t 1 -T 5 --spider $weather_spider || wget_error=$?
# grab the weather feed xml file
if [[ $wget_error -eq 0 ]];then
@ -8110,8 +8113,8 @@ get_weather_data()
data_grab_error="Error: weather server up but download error - wget: $wget_error"
fi
else
if [[ -f $testDir/weather-feed.xml ]];then
weather_data="$( cat $testDir/weather-feed.xml)"
if [[ -f $testDir$test_weather ]];then
weather_data="$( cat $testDir$test_weather)"
else
data_grab_error="Error: weather feed xml local file not found."
fi
@ -8127,7 +8130,7 @@ get_weather_data()
# we need to grab the location data from the feed for remote checks
if [[ -n $ALTERNATE_WEATHER_LOCATION ]];then
location_data=$( sed -e '/<current_observation>/,/<display_location>/d' -e '/<\/display_location>/,/<\/current_observation>/d' <<< "$weather_data" )
# echo "$location_data"
# echo -e "ld1:\n$location_data"
A_WEATHER_DATA[0]=$( gawk '
function clean(data) {
returnData=""
@ -8156,6 +8159,7 @@ get_weather_data()
END {
print city ";" state ";;;;" country
}' <<< "$location_data" )
# echo -e "location:\n${A_WEATHER_DATA[0]}"
fi
# clean off everything before/after observation_location

View file

@ -1,3 +1,15 @@
=====================================================================================
Version: 1.9.02
Patch Version: 00
Script Date: May 17 2013
-----------------------------------
Changes:
-----------------------------------
new version, new tarball, bug fix for weather
-----------------------------------
-- Harald Hope - Fri, 17 May 2013 21:10:21 -0700
=====================================================================================
Version: 1.9.01
Patch Version: 00