diff --git a/eventsource/request.py b/eventsource/request.py index 7d581e4..0527a69 100644 --- a/eventsource/request.py +++ b/eventsource/request.py @@ -2,7 +2,11 @@ import argparse import json -import urllib2 + +# urllib is tricky, maybe use Requests? +from future.standard_library import install_aliases +install_aliases() +import urllib.parse, urllib.request, urllib.error def send_json(url, data): """ @@ -75,12 +79,12 @@ def start(): try: if args.json: - print send_json("http://%(host)s:%(port)s/%(action)s/%(token)s" % args.__dict__, args.data) + print(send_json("http://%(host)s:%(port)s/%(action)s/%(token)s" % args.__dict__, args.data)) else: - print send_string("http://%(host)s:%(port)s/%(action)s/%(token)s" % args.__dict__, args.data) + print(send_string("http://%(host)s:%(port)s/%(action)s/%(token)s" % args.__dict__, args.data)) sys.exit(0) - except Exception, err: - print "Unable to send request (%s): %s" % (err, err.readline().split("")[-1].split("")[0]) + except Exception as err: + print("Unable to send request (%s): %s" % (err, err.readline().split("")[-1].split("")[0])) sys.exit(1) if __name__ == "__main__": diff --git a/setup.py b/setup.py index 81fe27a..8d25429 100644 --- a/setup.py +++ b/setup.py @@ -38,7 +38,8 @@ def read(*names): install_requires = [ 'tornado>=4.4', 'pycurl', - ] + (['future'] if sys.version_info.major == 2 else []), + 'future', + ], packages = find_packages(exclude=['examples', 'tests']), url='http://packages.python.org/eventsource/', include_package_data=True,