From ddbe326afee27e34c4b14793bda916b4a6144b35 Mon Sep 17 00:00:00 2001 From: Adrian Lopez Date: Fri, 20 Jan 2017 15:59:38 +0100 Subject: [PATCH 1/3] Adapted to python3 --- app.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app.py b/app.py index 784d9e571b..964b1a413e 100755 --- a/app.py +++ b/app.py @@ -1,6 +1,9 @@ #!/usr/bin/env python -import urllib +from __future__ import print_function +from future import standard_library +standard_library.install_aliases() +import urllib.request, urllib.parse, urllib.error import json import os @@ -35,8 +38,8 @@ def processRequest(req): yql_query = makeYqlQuery(req) if yql_query is None: return {} - yql_url = baseurl + urllib.urlencode({'q': yql_query}) + "&format=json" - result = urllib.urlopen(yql_url).read() + yql_url = baseurl + urllib.parse.urlencode({'q': yql_query}) + "&format=json" + result = urllib.request.urlopen(yql_url).read() data = json.loads(result) res = makeWebhookResult(data) return res @@ -95,6 +98,6 @@ def makeWebhookResult(data): if __name__ == '__main__': port = int(os.getenv('PORT', 5000)) - print "Starting app on port %d" % port + print("Starting app on port %d" % port) app.run(debug=False, port=port, host='0.0.0.0') From d88b945ecdfb65f44661f69e0dd68aabeee0bf03 Mon Sep 17 00:00:00 2001 From: Loris Mazloum Date: Tue, 24 Jan 2017 21:22:50 -0500 Subject: [PATCH 2/3] Add future to requirements.txt Allows deploy to Heroku button to work. --- requirements.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 56eeb0c801..a679b0f117 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ -Flask==0.10.1 \ No newline at end of file +Flask==0.10.1 +future==0.16.0 From 704d89341878c6d2dc07cc0395b863f38ee6ab6e Mon Sep 17 00:00:00 2001 From: Danil Skachkov Date: Fri, 17 Feb 2017 15:29:12 +0700 Subject: [PATCH 3/3] Fix for python2.7 --- app.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/app.py b/app.py index 964b1a413e..38ccc563ec 100755 --- a/app.py +++ b/app.py @@ -1,9 +1,13 @@ #!/usr/bin/env python from __future__ import print_function -from future import standard_library -standard_library.install_aliases() -import urllib.request, urllib.parse, urllib.error +from future.standard_library import install_aliases +install_aliases() + +from urllib.parse import urlparse, urlencode +from urllib.request import urlopen, Request +from urllib.error import HTTPError + import json import os @@ -38,8 +42,8 @@ def processRequest(req): yql_query = makeYqlQuery(req) if yql_query is None: return {} - yql_url = baseurl + urllib.parse.urlencode({'q': yql_query}) + "&format=json" - result = urllib.request.urlopen(yql_url).read() + yql_url = baseurl + urlencode({'q': yql_query}) + "&format=json" + result = urlopen(yql_url).read() data = json.loads(result) res = makeWebhookResult(data) return res