Fix KeyError when no results in time period

Fix a KeyError when no results were found for the specified time period.
pull/3/head
Will Urbanski 2015-11-22 17:52:12 -05:00
parent 205baa2f65
commit b5acf414e9
1 changed files with 6 additions and 2 deletions

View File

@ -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']: