added try/except around etcdclient.read to cater if EtcdKeyNotFound
This commit is contained in:
parent
1cd8eee616
commit
55dfda523b
1 changed files with 5 additions and 2 deletions
|
@ -3,7 +3,7 @@ import requests
|
||||||
|
|
||||||
from decouple import config
|
from decouple import config
|
||||||
from pyotp import TOTP
|
from pyotp import TOTP
|
||||||
|
from etcd import EtcdKeyNotFound
|
||||||
|
|
||||||
def check_otp(name, realm, seed):
|
def check_otp(name, realm, seed):
|
||||||
try:
|
try:
|
||||||
|
@ -29,7 +29,10 @@ def check_otp(name, realm, seed):
|
||||||
|
|
||||||
|
|
||||||
def get_next_id(client, path):
|
def get_next_id(client, path):
|
||||||
|
try:
|
||||||
r = client.read(path)
|
r = client.read(path)
|
||||||
|
except EtcdKeyNotFound:
|
||||||
|
return 0
|
||||||
|
|
||||||
max_key_result = max(r.children, key=lambda x: int(strip_nondigit(x.key)))
|
max_key_result = max(r.children, key=lambda x: int(strip_nondigit(x.key)))
|
||||||
if max_key_result is None:
|
if max_key_result is None:
|
||||||
|
|
Loading…
Reference in a new issue