From 55dfda523b7c5a80d81a11e8a69978df0e558bd9 Mon Sep 17 00:00:00 2001 From: Ahmad Bilal Khalid Date: Mon, 24 Jun 2019 16:39:53 +0500 Subject: [PATCH] added try/except around etcdclient.read to cater if EtcdKeyNotFound --- helper.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/helper.py b/helper.py index a426ec4..deaf313 100644 --- a/helper.py +++ b/helper.py @@ -3,7 +3,7 @@ import requests from decouple import config from pyotp import TOTP - +from etcd import EtcdKeyNotFound def check_otp(name, realm, seed): try: @@ -29,7 +29,10 @@ def check_otp(name, realm, seed): def get_next_id(client, path): - r = client.read(path) + try: + r = client.read(path) + except EtcdKeyNotFound: + return 0 max_key_result = max(r.children, key=lambda x: int(strip_nondigit(x.key))) if max_key_result is None: