[GRASS-SVN] r56214 - grass/branches/develbranch_6/scripts/r.in.wms
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun May 12 05:00:26 PDT 2013
Author: hamish
Date: 2013-05-12 05:00:26 -0700 (Sun, 12 May 2013)
New Revision: 56214
Modified:
grass/branches/develbranch_6/scripts/r.in.wms/r.in.wms
grass/branches/develbranch_6/scripts/r.in.wms/wms.download
Log:
rewrite eval loop to be safe for spaces in path names; minor indent sanitation
Modified: grass/branches/develbranch_6/scripts/r.in.wms/r.in.wms
===================================================================
--- grass/branches/develbranch_6/scripts/r.in.wms/r.in.wms 2013-05-12 11:40:23 UTC (rev 56213)
+++ grass/branches/develbranch_6/scripts/r.in.wms/r.in.wms 2013-05-12 12:00:26 UTC (rev 56214)
@@ -458,9 +458,9 @@
#### Exit if there is no map
# It would be a good idea to test if the map already exists here too
-if [ -z "${GIS_OPT_OUTPUT}" ] ; then
- g.message -e "No output map specified"
- exit 1;
+if [ -z "$GIS_OPT_OUTPUT" ] ; then
+ g.message -e "No output map specified"
+ exit 1
fi
REQUEST=""
@@ -530,20 +530,23 @@
# Job 2: make list of files
-CONTENTS=`cat "$REQUESTFILE"`
-
FILES=""
COUNT=0
-for line in $CONTENTS ; do
- eval "$line"
- if [ $COUNT -eq 0 ] ; then
- FILES="$OUTPUT_FILE"
- else
- FILES="$FILES,$OUTPUT_FILE"
- fi
- COUNT=`expr $COUNT + 1`
-done
+while read line ; do
+ if [ -z "$line" ] ; then
+ continue
+ fi
+ eval "$line"
+ if [ "$COUNT" -eq 0 ] ; then
+ FILES="$OUTPUT_FILE"
+ else
+ FILES="$FILES,$OUTPUT_FILE"
+ fi
+ COUNT=`expr "$COUNT" + 1`
+done < "$REQUESTFILE"
+
+
addflag GDALWARP c 1
addflag GDALWARP k "$GIS_FLAG_K"
addflag GDALWARP p "$GIS_FLAG_P"
Modified: grass/branches/develbranch_6/scripts/r.in.wms/wms.download
===================================================================
--- grass/branches/develbranch_6/scripts/r.in.wms/wms.download 2013-05-12 11:40:23 UTC (rev 56213)
+++ grass/branches/develbranch_6/scripts/r.in.wms/wms.download 2013-05-12 12:00:26 UTC (rev 56214)
@@ -91,9 +91,9 @@
#
exitprocedure()
{
- g.message -e 'User break!'
- rm -f "$TEMPFILE"*
- exit 1
+ g.message -e 'User break!'
+ rm -f "$TEMPFILE"*
+ exit 1
}
trap "exitprocedure" 2 3 15
@@ -114,20 +114,23 @@
################################################################
# Download the tiles!!
GetTiles() {
- g.message "Downloading tiles"
+ g.message "Downloading tiles"
- # init POST-data vs. GET URL method variable
- if [ "$GIS_FLAG_G" -eq 0 ] ; then
- POST_DATA_OK=1
- else
- POST_DATA_OK=0
- fi
+ # init POST-data vs. GET URL method variable
+ if [ "$GIS_FLAG_G" -eq 0 ] ; then
+ POST_DATA_OK=1
+ else
+ POST_DATA_OK=0
+ fi
- CONTENTS=`cat "$REQUESTFILE"`
+ NUMBER_OF_TILES=0
- NUMBER_OF_TILES=0
- for line in $CONTENTS ; do
+ while read line ; do
g.message -d message="wget command: [$line]" debug=2
+ if [ -z "$line" ] ; then
+ continue
+ fi
+
eval "$line"
emptyness=`file "$OUTPUT_FILE" | grep empty$`
@@ -137,18 +140,18 @@
else
GetData
if [ $? -ne 0 ] ; then
- NUMBER_OF_TILES=`expr $NUMBER_OF_TILES + 1`
+ NUMBER_OF_TILES=`expr $NUMBER_OF_TILES + 1`
fi
fi
- done
+ done < "$REQUESTFILE"
- if [ $NUMBER_OF_TILES -ne 0 ] ; then
- g.message -w "$NUMBER_OF_TILES failed to download"
- return 1
- else
- g.message "All tiles downloaded successfully"
- return 0
- fi
+ if [ "$NUMBER_OF_TILES" -ne 0 ] ; then
+ g.message -w "$NUMBER_OF_TILES tiles failed to download"
+ return 1
+ else
+ g.message "All tiles downloaded successfully"
+ return 0
+ fi
}
##################################
More information about the grass-commit
mailing list