From b1f4fade6e8875fbb8fb167e8a5273390e9d1635 Mon Sep 17 00:00:00 2001 From: tatwell Date: Sat, 25 Jul 2015 21:49:45 -0700 Subject: [PATCH 1/5] Creates branch hbyjknty-arrow-api and updates app.yaml version. --- app-engine/app.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app-engine/app.yaml b/app-engine/app.yaml index 6146665..413c6ac 100644 --- a/app-engine/app.yaml +++ b/app-engine/app.yaml @@ -4,7 +4,7 @@ # for details. # default: production -version: dev +version: hbyjknty application: tatwell-python-demo runtime: python27 From b5ce1c3aacd47c38d8116bd532d855ea8a5f3438 Mon Sep 17 00:00:00 2001 From: tatwell Date: Sat, 25 Jul 2015 22:05:00 -0700 Subject: [PATCH 2/5] Adds arrow library and arrow/version endpoint. --- app-engine/main.py | 15 ++++++++++++++- app-engine/requirements.txt | 6 ++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/app-engine/main.py b/app-engine/main.py index fa98f67..db523b4 100644 --- a/app-engine/main.py +++ b/app-engine/main.py @@ -3,7 +3,7 @@ # from os.path import dirname, join -from flask import Flask, render_template +from flask import Flask, render_template, jsonify # @@ -27,6 +27,19 @@ def main_index(): """Home page.""" return render_template('index.html') +# Arrow API +# Mainly to test fix for this issue: +# +@app.route('/arrow/version', methods=['GET']) +def arrow_version(): + import arrow + import dateutil + + return jsonify({ + 'arrow': arrow.VERSION, + 'dateutil': dateutil.__version__ + }) + # # Exception Handlers diff --git a/app-engine/requirements.txt b/app-engine/requirements.txt index a257e29..7f261cf 100644 --- a/app-engine/requirements.txt +++ b/app-engine/requirements.txt @@ -5,3 +5,9 @@ # # Note: The `lib` directory is added to `sys.path` by `appengine_config.py`. Flask==0.10 + +# Arrow requires dateutil and dateutil > 1.5 require subprocess which App Engine +# does not allow. So we peg it here. +# See https://github.com/crsmithdev/arrow/issues/240 +arrow +python-dateutil==1.5 From 3c079b6c84c8f36d535e5fa85ceb3d177a47ddf4 Mon Sep 17 00:00:00 2001 From: tatwell Date: Sun, 26 Jul 2015 08:04:33 -0700 Subject: [PATCH 3/5] Adds functioning endpoint for arrow.now. --- app-engine/main.py | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/app-engine/main.py b/app-engine/main.py index db523b4..5b5c860 100644 --- a/app-engine/main.py +++ b/app-engine/main.py @@ -2,6 +2,8 @@ # Imports # from os.path import dirname, join +import arrow +import dateutil from flask import Flask, render_template, jsonify @@ -30,16 +32,32 @@ def main_index(): # Arrow API # Mainly to test fix for this issue: # -@app.route('/arrow/version', methods=['GET']) +@app.route('/arrow/version') def arrow_version(): - import arrow - import dateutil - return jsonify({ 'arrow': arrow.VERSION, 'dateutil': dateutil.__version__ }) +@app.route('/arrow/now') +@app.route('/arrow/now/') +def arrow_now(timezone=None): + now = arrow.utcnow() + json_data = { + 'now': str(now), + 'timezone': 'UTC' + } + + if timezone: + timezone = timezone.replace('-', '/') + json_data['timezone'] = timezone + try: + json_data['now'] = str(now.to(timezone)) + except arrow.parser.ParserError, e: + json_data['now'] = None + json_data['error'] = str(e) + + return jsonify(json_data) # # Exception Handlers From e94e99e8c2021d3c75711a3d9e65e619c08de466 Mon Sep 17 00:00:00 2001 From: tatwell Date: Sun, 26 Jul 2015 08:18:50 -0700 Subject: [PATCH 4/5] Updates comment in pip requirements file. --- app-engine/requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app-engine/requirements.txt b/app-engine/requirements.txt index 7f261cf..b25eada 100644 --- a/app-engine/requirements.txt +++ b/app-engine/requirements.txt @@ -6,8 +6,8 @@ # Note: The `lib` directory is added to `sys.path` by `appengine_config.py`. Flask==0.10 -# Arrow requires dateutil and dateutil > 1.5 require subprocess which App Engine -# does not allow. So we peg it here. +# Arrow requires dateutil and dateutil > 1.5 required subprocess module which App Engine +# does not allow. So we peg dateutil here to 1.5. # See https://github.com/crsmithdev/arrow/issues/240 arrow python-dateutil==1.5 From eaadc06d9e4ea9b103ce8f0429334bd7f4be5fd7 Mon Sep 17 00:00:00 2001 From: tatwell Date: Sun, 26 Jul 2015 08:19:58 -0700 Subject: [PATCH 5/5] Fixes typo in comment. --- app-engine/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app-engine/requirements.txt b/app-engine/requirements.txt index b25eada..efe7017 100644 --- a/app-engine/requirements.txt +++ b/app-engine/requirements.txt @@ -6,7 +6,7 @@ # Note: The `lib` directory is added to `sys.path` by `appengine_config.py`. Flask==0.10 -# Arrow requires dateutil and dateutil > 1.5 required subprocess module which App Engine +# Arrow requires dateutil and dateutil > 1.5 requires subprocess module which App Engine # does not allow. So we peg dateutil here to 1.5. # See https://github.com/crsmithdev/arrow/issues/240 arrow