Woof2
Check-in [fb69ed779d]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
SHA1 Hash:fb69ed779d35703192a16566d09800720aec617a
Date: 2012-02-20 10:38:49
User: BarryK
Comment:jemimah: improve ui for /usr/sbin/download_file
Tags And Properties
Changes
hide diffs unified diffs patch

Changes to woof-code/rootfs-skeleton/usr/sbin/download_file

Old (9293b575be5d24d9) New (d14c06329be69d92)
1 #!/bin/sh 1 #!/bin/sh
2 #(c) Copyright Barry Kauler 2010. License GPL v3 /usr/share/doc/legal. 2 #(c) Copyright Barry Kauler 2010. License GPL v3 /usr/share/doc/legal.
3 #BK a simple frontend for wget. 3 #BK a simple frontend for wget.
4 #URL passed in, only downloads to current directory. 4 #URL passed in, only downloads to current directory.
5 #only put up user-response dlg windows if failure. 5 #only put up user-response dlg windows if failure.
2 hidden lines
8 #101118 for ftp connection have to get size differently. 8 #101118 for ftp connection have to get size differently.
9 #101126 not sure, it seems that wget now defaults to ipv6, fails for some users, use '-4' to force ipv4. 9 #101126 not sure, it seems that wget now defaults to ipv6, fails for some users, use '-4' to force ipv4.
10 #101206 fix find filesize ftp://ftp.lug.udel.edu/pub/puppylinux ... 10 #101206 fix find filesize ftp://ftp.lug.udel.edu/pub/puppylinux ...
11 #120201 rodin.s: internationalized. Add LANG=C to 1-st wget for proper work 11 #120201 rodin.s: internationalized. Add LANG=C to 1-st wget for proper work
12 #120218 removed a LANG=C line (line 43). 12 #120218 removed a LANG=C line (line 43).
> 13 #120220 jemimah: Technosaurus' wget progressbar function to the download_file utility. It also replaces an rxvt window with an Xdialog tailbox. refer: http://murga-linux.com/puppy/viewtopic.php?t=71767&start=420
13 14
14 # adding gettext 15 # adding gettext
15 export TEXTDOMAINDIR=/usr/share/locale 16 export TEXTDOMAINDIR=/usr/share/locale
16 export TEXTDOMAIN=download_file 17 export TEXTDOMAIN=download_file
17 eval_gettext () { 18 eval_gettext () {
15 hidden lines
33 34
34 #test url... -t 2 means try 2 times, -T 20 means timeout in 20 seconds 35 #test url... -t 2 means try 2 times, -T 20 means timeout in 20 seconds
35 while [ 1 ];do 36 while [ 1 ];do
36 echo -n "" > /tmp/download_file_spider.log1 37 echo -n "" > /tmp/download_file_spider.log1
37 #gtklogfileviewer "/tmp/download_file_spider.log" "Close" 0 0 600 200 "Testing remote file exists:" & 38 #gtklogfileviewer "/tmp/download_file_spider.log" "Close" 0 0 600 200 "Testing remote file exists:" &
38 rxvt -geometry 130x10+0+0 -bg orange -fg black -title "$(gettext 'Testing file exists:') ${URLSPEC}" -e tail -f /tmp/download_file_spider.log1 & | 39 #rxvt -geometry 130x10+0+0 -bg orange -fg black -title "$(gettext 'Testing file exists:') ${URLSPEC}" -e tail -f /tmp/download_file_spider.log1 &
| 40 Xdialog --wmclass "gtkdialog2" --title "$(gettext 'Testing file exists:') ${URLSPEC}" --tailbox /tmp/download_file_spider.log1 30 100 & #120220
39 PID1=$! 41 PID1=$!
40 LANG=C wget -4 -t 2 -T 20 --waitretry=20 --spider -S "${URLSPEC}" > /tmp/download_file_spider.log1 2>&1 # 42 LANG=C wget -4 -t 2 -T 20 --waitretry=20 --spider -S "${URLSPEC}" > /tmp/download_file_spider.log1 2>&1 #
41 if [ $? -ne 0 ];then 43 if [ $? -ne 0 ];then
42 Xdialog --wmclass "gtkdialog2" --title "$(gettext 'Puppy File Downloader')" --screen-center --cr-wrap --ok-label "$(gettext 'TEST AGAIN')" --cancel-label "$(gettext 'GIVE UP')" --icon "/usr/local/lib/X11/pixmaps/error.xpm" --yesno "$(gettext 'Tested if remote file exists, but failed, see log top-left of screen. 44 Xdialog --wmclass "gtkdialog2" --title "$(gettext 'Puppy File Downloader')" --screen-center --cr-wrap --ok-label "$(gettext 'TEST AGAIN')" --cancel-label "$(gettext 'GIVE UP')" --icon "/usr/local/lib/X11/pixmaps/error.xpm" --yesno "$(gettext 'Tested if remote file exists, but failed, see log top-left of screen.
43 Do you want to test again, or give up?')" 0 0 45 Do you want to test again, or give up?')" 0 0
134 hidden lines
178 fi 180 fi
179 fi 181 fi
180 fi 182 fi
181 183
182 echo -n "" > /tmp/download_file_spider.log2 184 echo -n "" > /tmp/download_file_spider.log2
183 rxvt -geometry 130x10+0+0 -bg orange -fg black -title "$(gettext 'Downloading file:') ${URLSPEC}" -e tail -f /tmp/download_file_spider.log2 & | 185 #rxvt -geometry 130x10+0+0 -bg orange -fg black -title "$(gettext 'Downloading file:') ${URLSPEC}" -e tail -f /tmp/download_file_spider.log2 &
| 186 #120220 jemimah...
| 187 tail -f /tmp/download_file_spider.log2 | while read LINE; do
| 188 case $LINE in
| 189 *%*)LINE=${LINE##*..};echo ${LINE%%%*};;
| 190 esac
| 191 done |Xdialog --gauge "$(gettext 'Downloading file:') ${URLSPEC}" 0 0&
184 PID1=$! 192 PID1=$!
185 #-t 5 means retry 5 times, -w 5 means wait 5 seconds between retries... 193 #-t 5 means retry 5 times, -w 5 means wait 5 seconds between retries...
186 wget -4 ${CONTPARAM} -t 5 -w 5 "${URLSPEC}" > /tmp/download_file_spider.log2 2>&1 194 wget -4 ${CONTPARAM} -t 5 -w 5 "${URLSPEC}" > /tmp/download_file_spider.log2 2>&1
187 if [ $? -ne 0 ];then 195 if [ $? -ne 0 ];then
188 Xdialog --wmclass "gtkdialog2" --title "$(gettext 'Puppy File Downloader')" --screen-center --cr-wrap --ok-label "$(gettext 'TRY AGAIN')" --cancel-label "$(gettext 'GIVE UP')" --icon "/usr/local/lib/X11/pixmaps/error.xpm" --yesno "$(gettext 'Download failed, see log top-left of screen. 196 Xdialog --wmclass "gtkdialog2" --title "$(gettext 'Puppy File Downloader')" --screen-center --cr-wrap --ok-label "$(gettext 'TRY AGAIN')" --cancel-label "$(gettext 'GIVE UP')" --icon "/usr/local/lib/X11/pixmaps/error.xpm" --yesno "$(gettext 'Download failed, see log top-left of screen.
16 hidden lines
205 break 213 break
206 done 214 done
207 215
208 exit 0 216 exit 0
209 ###END### 217 ###END###