diff options
Diffstat (limited to 'tests/fixtureapps/getline.py')
-rw-r--r-- | tests/fixtureapps/getline.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/fixtureapps/getline.py b/tests/fixtureapps/getline.py new file mode 100644 index 0000000..5e0ad3a --- /dev/null +++ b/tests/fixtureapps/getline.py @@ -0,0 +1,17 @@ +import sys + +if __name__ == "__main__": + try: + from urllib.request import urlopen, URLError + except ImportError: + from urllib2 import urlopen, URLError + + url = sys.argv[1] + headers = {"Content-Type": "text/plain; charset=utf-8"} + try: + resp = urlopen(url) + line = resp.readline().decode("ascii") # py3 + except URLError: + line = "failed to read %s" % url + sys.stdout.write(line) + sys.stdout.flush() |