[gpsbabel] Add and document gpsbabel-download-latest.py
Hans Ulrich Niedermann
ndim at fedoraproject.org
Fri Jan 21 19:04:12 UTC 2011
commit edb9351439d9bd444ddfc47780f28a576c208b62
Author: Hans Ulrich Niedermann <hun at n-dimensional.de>
Date: Fri Jan 21 19:59:41 2011 +0100
Add and document gpsbabel-download-latest.py
As upstream only offers HTTP POST downloads, and only of the
latest tarball, we add a BeautifulSoup based download script
to fetch the very latest source tarball.
gpsbabel-download-latest.py | 54 +++++++++++++++++++++++++++++++++++++++++++
gpsbabel.spec | 24 +++++++++++--------
2 files changed, 68 insertions(+), 10 deletions(-)
---
diff --git a/gpsbabel-download-latest.py b/gpsbabel-download-latest.py
new file mode 100755
index 0000000..27e0774
--- /dev/null
+++ b/gpsbabel-download-latest.py
@@ -0,0 +1,54 @@
+#!/usr/bin/python
+
+import re
+import urllib2
+import subprocess
+from BeautifulSoup import BeautifulSoup
+
+download_url = "http://www.gpsbabel.org/download.html"
+
+print "Loading HTML page", download_url
+
+page = urllib2.urlopen(download_url)
+# print "page:", page
+
+soup = BeautifulSoup(page)
+# print "soup:", soup
+
+rexp = re.compile('\.tar\.gz$')
+
+def test_tag(tag):
+ if tag.name != 'form': return False
+ if tag['action'] != 'plan9.php': return False
+ if tag['method'] != 'post': return False
+ if tag['enctype'] != 'multipart/form-data': return False
+ found = tag.find('input', value=rexp)
+ return found
+
+tarball_form = soup.find(test_tag)
+form_inputs = tarball_form.findAll('input')
+
+d = dict([ (input['name'], input['value']) for input in form_inputs ])
+# print d
+
+tarball = d[u'dl']
+token = d[u'token']
+
+# print "tarball:", tarball
+# print "token:", token
+
+cmd = [ 'curl',
+ '-F', "=".join(['dl', tarball]),
+ '-F', "=".join(['token', token]),
+ '-e', download_url,
+ 'http://www.gpsbabel.org/plan9.php',
+ '-o', tarball ]
+# print "Command:", cmd
+
+print "Running curl to get tarball via HTTP POST:", tarball
+retcode = subprocess.call(cmd, shell=False)
+
+if retcode == 0:
+ print "Successfully downloaded tarball:", tarball
+else:
+ print "Error downloading tarball (%d):" % retcode, tarball
diff --git a/gpsbabel.spec b/gpsbabel.spec
index d67855e..7ada3b7 100644
--- a/gpsbabel.spec
+++ b/gpsbabel.spec
@@ -6,17 +6,21 @@ Summary: A tool to convert between various formats used by GPS devices
Group: Applications/Text
License: GPLv2+
URL: http://www.gpsbabel.org
-# Source can only be downloaded via HTTP POST. Run
+# There is no Source0 URL as upstream only offers download via HTTP
+# POST, and only for the latest release. Point your web browser to
+# http://www.gpsbabel.org/download.html, scroll down to the linux
+# source tarball download button and click on it. Or try the included
+# gpsbabel-download-latest.py script to download the latest tarball
+# (requires the python-BeautifulSoup package):
#
-# curl -F "dl=gpsbabel-1.4.2.tar.gz" \
-# -F "token=a1aad879" \
-# http://www.gpsbabel.org/plan9.php \
-# -o gpsbabel-1.4.2.tar.gz
-#
-# which will probably stop working again in a jiffy, so you'll better
-# point your elinks/firefox/etc at
-# http://www.gpsbabel.org/download.html and click on the linux source
-# download button.
+# $ ./gpsbabel-download-latest.py
+# Loading HTML page http://www.gpsbabel.org/download.html
+# Running curl to get tarball via HTTP POST: gpsbabel-1.4.2.tar.gz
+# % Total % Received % Xferd Average Speed Time Time Time Current
+# Dload Upload Total Spent Left Speed
+# 100 5421k 100 5421k 100 260 252k 12 0:00:21 0:00:21 --:--:-- 263k
+# Successfully downloaded tarball: gpsbabel-1.4.2.tar.gz
+# $
Source0: %{name}-%{version}.tar.gz
Source1: %{name}.desktop
Source2: %{name}.png
More information about the scm-commits
mailing list