From b5acf414e9fcbecee8da15e2757a60ce10cc5c10 Mon Sep 17 00:00:00 2001 From: Will Urbanski Date: Sun, 22 Nov 2015 17:52:12 -0500 Subject: [PATCH] Fix KeyError when no results in time period Fix a KeyError when no results were found for the specified time period. --- examples/last.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/examples/last.py b/examples/last.py index 7cb0cf1..bdf4159 100755 --- a/examples/last.py +++ b/examples/last.py @@ -18,8 +18,12 @@ def init(url, key): def download_last(m, last, out=None): result = m.download_last(last) if out is None: - for e in result['response']: - print(json.dumps(e) + '\n') + if 'response' in result: + for e in result['response']: + print(json.dumps(e) + '\n') + else: + print('No results for that time period') + exit(0) else: with open(out, 'w') as f: for e in result['response']: