summaryrefslogtreecommitdiff
path: root/tests/fixtureapps/getline.py
blob: 5e0ad3ae5ff1bdb59e81c936b7aa6ea5e9a7331d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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()