diff options
author | Johannes Löthberg <johannes@kyriasis.com> | 2015-06-21 13:58:26 +0100 |
---|---|---|
committer | Johannes Löthberg <johannes@kyriasis.com> | 2015-06-21 13:59:05 +0100 |
commit | d6c7f690b7b65fc7d995dc3d739db355a4a6a2fd (patch) | |
tree | 1ac034f5c827344bc68f40cdc31cf9d043a1ff1a /src | |
parent | 296c5652f000a7b3da0eea2df76062143c56c80d (diff) | |
download | fingerchange-d6c7f690b7b65fc7d995dc3d739db355a4a6a2fd.tar.xz |
Fail gracefully on empty results
Diffstat (limited to 'src')
-rwxr-xr-x | src/fingerchange.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/fingerchange.py b/src/fingerchange.py index b34c009..952822f 100755 --- a/src/fingerchange.py +++ b/src/fingerchange.py @@ -23,7 +23,10 @@ def get_user_by_uid(site, uid): res = requests.get(api_url + str(uid), params=params) res = json.loads(res.text) - return res['items'][0] + if 'items' in res and len(res['items']) > 0: + return res['items'][0] + else: + return def get_users_by_name(site, name=''): @@ -35,7 +38,10 @@ def get_users_by_name(site, name=''): res = requests.get(api_url, params=params) res = json.loads(res.text) - return res['items'] + if 'items' in res: + return res['items'] + else: + return [] def format_url(url): |