diff options
author | Blair Bonnett | 2019-02-15 06:30:21 +0100 |
---|---|---|
committer | Blair Bonnett | 2019-02-15 06:30:21 +0100 |
commit | 0b408bc3ae12e857e5e018f2c9ef34c564214f91 (patch) | |
tree | 283698c4a2d7088e713868fdb12a9d0b1cf92df2 | |
parent | e6ecc368ae22afa1065ca6ac675ce66d9df512d8 (diff) | |
download | aur-0b408bc3ae12e857e5e018f2c9ef34c564214f91.tar.gz |
Patch in unreleased Python 3 and timeout support.
-rw-r--r-- | .SRCINFO | 6 | ||||
-rw-r--r-- | PKGBUILD | 20 | ||||
-rw-r--r-- | python3.patch | 93 | ||||
-rw-r--r-- | timeout.patch | 72 |
4 files changed, 187 insertions, 4 deletions
@@ -1,13 +1,17 @@ pkgbase = wispr pkgdesc = Simple command-line tool to authenticate against a WISPr server pkgver = 1.0 - pkgrel = 1 + pkgrel = 2 url = https://github.com/wichert/wispr arch = any license = custom depends = python source = https://github.com/wichert/wispr/archive/release/1.0.tar.gz + source = python3.patch + source = timeout.patch sha256sums = ba9994abee90d51c9d65fbb61241694a610a0198c5c4a833f8d7bf9c346ebd41 + sha256sums = 7f14a07b35f7625b90163352ef943d225ef4ba01a5aa172e67174157e1b4b2cf + sha256sums = 0cc5f11d022ff3c560f71ce7c7269dd55a50a31ba1ee9c230e0405801b777eb5 pkgname = wispr @@ -2,14 +2,28 @@ pkgname=wispr pkgver=1.0 -pkgrel=1 +pkgrel=2 pkgdesc="Simple command-line tool to authenticate against a WISPr server" url="https://github.com/wichert/wispr" arch=('any') license=('custom') depends=('python') -source=('https://github.com/wichert/wispr/archive/release/1.0.tar.gz') -sha256sums=('ba9994abee90d51c9d65fbb61241694a610a0198c5c4a833f8d7bf9c346ebd41') +source=( + 'https://github.com/wichert/wispr/archive/release/1.0.tar.gz' + 'python3.patch' + 'timeout.patch' +) +sha256sums=( + 'ba9994abee90d51c9d65fbb61241694a610a0198c5c4a833f8d7bf9c346ebd41' + '7f14a07b35f7625b90163352ef943d225ef4ba01a5aa172e67174157e1b4b2cf' + '0cc5f11d022ff3c560f71ce7c7269dd55a50a31ba1ee9c230e0405801b777eb5' +) + +prepare() { + cd "wispr-release-$pkgver" + patch -Np1 -i ../../python3.patch + patch -Np1 -i ../../timeout.patch +} build() { cd "wispr-release-$pkgver" diff --git a/python3.patch b/python3.patch new file mode 100644 index 000000000000..858cbfaf93d9 --- /dev/null +++ b/python3.patch @@ -0,0 +1,93 @@ +diff -Naur wispr-release-1.0/changes.rst wisprpy3/changes.rst +--- wispr-release-1.0/changes.rst 1970-01-01 01:00:00.000000000 +0100 ++++ wisprpy3/changes.rst 2019-02-15 06:22:13.418704328 +0100 +@@ -0,0 +1,13 @@ ++Changelog ++========= ++ ++1.1 - Unreleased ++-------------------- ++ ++- Support Python 3 as well. ++ ++ ++1.0 - 28 August 2015 ++-------------------- ++ ++- First release. +diff -Naur wispr-release-1.0/setup.py wisprpy3/setup.py +--- wispr-release-1.0/setup.py 2015-08-28 18:53:47.000000000 +0200 ++++ wisprpy3/setup.py 2019-02-15 06:21:10.990237827 +0100 +@@ -1,7 +1,7 @@ + from setuptools import find_packages + from setuptools import setup + +-version = '1.0' ++version = '1.1' + + setup( + version=version, +@@ -15,6 +15,11 @@ + 'License :: OSI Approved :: BSD License', + 'Operating System :: OS Independent', + 'Intended Audience :: End Users/Desktop', ++ 'Programming Language :: Python :: 2', ++ 'Programming Language :: Python :: 2.7', ++ 'Programming Language :: Python :: 3', ++ 'Programming Language :: Python :: 3.4', ++ 'Programming Language :: Python :: 3.5', + ], + author='Wichert Akkerman', + author_email='wichert@wiggy.net', +diff -Naur wispr-release-1.0/src/wispr/__init__.py wisprpy3/src/wispr/__init__.py +--- wispr-release-1.0/src/wispr/__init__.py 2015-08-28 18:53:47.000000000 +0200 ++++ wisprpy3/src/wispr/__init__.py 2019-02-15 06:22:13.418704328 +0100 +@@ -6,7 +6,10 @@ + import sys + import time + import xml.sax.saxutils +-import urlparse ++try: ++ import urlparse ++except ImportError: ++ import urllib.parse as urlparse + import requests + + +@@ -32,7 +35,7 @@ + def parse_wispr(r): + m = re.search( + r'<WISPAccessGatewayParam.*?>\s*<(.*?)>(.*)</\1>\s*</WISPAccessGatewayParam>', +- r.content, re.I|re.S) ++ r.text, re.I|re.S) + data = {} + if m is None: + return data +@@ -122,11 +125,11 @@ + def detect(): + r = requests.get('http://www.google.com', allow_redirects=False, verify=False) + while r.status_code in [302, 304]: +- if 'WISPAccessGatewayParam' in r.content: ++ if 'WISPAccessGatewayParam' in r.text: + break + else: + r = requests.get(r.headers['Location'], allow_redirects=False, verify=False) +- if 'WISPAccessGatewayParam' not in r.content: ++ if 'WISPAccessGatewayParam' not in r.text: + if 'google' in urlparse.urlparse(r.url).hostname: + print('Already online, no WISPr detection possible') + else: +@@ -145,11 +148,11 @@ + def wispr_login(username, password): + r = requests.get('http://www.google.com', allow_redirects=False, verify=False) + while r.status_code in [302, 304]: +- if 'WISPAccessGatewayParam' in r.content: ++ if 'WISPAccessGatewayParam' in r.text: + break + else: + r = requests.get(r.headers['Location'], allow_redirects=False, verify=False) +- if 'WISPAccessGatewayParam' in r.content: ++ if 'WISPAccessGatewayParam' in r.text: + return do_wispr_login(r, username, password) + host = urlparse.urlparse(r.url).hostname + if 'google' in host: diff --git a/timeout.patch b/timeout.patch new file mode 100644 index 000000000000..a52d594df7da --- /dev/null +++ b/timeout.patch @@ -0,0 +1,72 @@ +diff -Naur wisprpep8/changes.rst wisprtimeout/changes.rst +--- wisprpep8/changes.rst 2019-02-15 06:27:03.836857275 +0100 ++++ wisprtimeout/changes.rst 2019-02-15 06:25:46.474801521 +0100 +@@ -6,6 +6,8 @@ + + - Support Python 3 as well. + ++- Set a timeout during initial requests. ++ + + 1.0 - 28 August 2015 + -------------------- +diff -Naur wisprpep8/src/wispr/__init__.py wisprtimeout/src/wispr/__init__.py +--- wisprpep8/src/wispr/__init__.py 2019-02-15 06:27:03.836857275 +0100 ++++ wisprtimeout/src/wispr/__init__.py 2019-02-15 06:25:46.474801521 +0100 +@@ -12,6 +12,7 @@ + import urllib.parse as urlparse + import requests + ++TIMEOUT = 5 + + MSG_REDIRECT = '100' + MSG_PROXY = '110' +@@ -123,12 +124,17 @@ + + + def detect(): +- r = requests.get('http://www.google.com', allow_redirects=False, verify=False) ++ try: ++ r = requests.get('http://www.google.com', allow_redirects=False, verify=False, timeout=TIMEOUT) ++ except requests.exceptions.ConnectionError as e: ++ print('Error testing for network. Perhaps you are not connected to a network?', ++ file=sys.stderr) ++ return False + while r.status_code in [302, 304]: + if 'WISPAccessGatewayParam' in r.text: + break + else: +- r = requests.get(r.headers['Location'], allow_redirects=False, verify=False) ++ r = requests.get(r.headers['Location'], allow_redirects=False, verify=False, timeout=TIMEOUT) + if 'WISPAccessGatewayParam' not in r.text: + if 'google' in urlparse.urlparse(r.url).hostname: + print('Already online, no WISPr detection possible') +@@ -146,12 +152,17 @@ + + + def wispr_login(username, password): +- r = requests.get('http://www.google.com', allow_redirects=False, verify=False) ++ try: ++ r = requests.get('http://www.google.com', allow_redirects=False, verify=False, timeout=TIMEOUT) ++ except requests.exceptions.ConnectionError as e: ++ print('Error testing for network. Perhaps you are not connected to a network?', ++ file=sys.stderr) ++ return False + while r.status_code in [302, 304]: + if 'WISPAccessGatewayParam' in r.text: + break + else: +- r = requests.get(r.headers['Location'], allow_redirects=False, verify=False) ++ r = requests.get(r.headers['Location'], allow_redirects=False, verify=False, timeout=TIMEOUT) + if 'WISPAccessGatewayParam' in r.text: + return do_wispr_login(r, username, password) + host = urlparse.urlparse(r.url).hostname +@@ -212,7 +223,7 @@ + else: + return wispr_login(options.username, options.password) + except requests.exceptions.ConnectionError as e: +- print('Error connecting to server: %s' % e) ++ print('Error connecting to server: %s' % e, file=sys.stderr) + except KeyboardInterrupt: + print('Aborting') + return False |