added try/except around etcdclient.read to cater if EtcdKeyNotFound

This commit is contained in:
ahmadbilalkhalid 2019-06-24 16:39:53 +05:00
parent 1cd8eee616
commit 55dfda523b

View file

@ -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):
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: