List yubikeys

This commit is contained in:
Jake Howard 2016-05-18 22:19:01 +01:00
parent 2e9e58d8f4
commit 136ce6e4b0
4 changed files with 24 additions and 0 deletions

View file

14
yubi_lock/api/yubikey.py Normal file
View file

@ -0,0 +1,14 @@
import yubico
def get_all_yubikeys(debug):
keys = []
try:
skip = 0
while skip < 255:
key = yubico.find_yubikey(debug=debug, skip=skip)
keys.append(key)
skip += 1
except yubico.yubikey.YubiKeyError:
pass
return keys

View file

10
yubi_lock/status/cli.py Normal file
View file

@ -0,0 +1,10 @@
import click
from yubi_lock.api.yubikey import get_all_yubikeys
@click.command('status', short_help='List connected devices.')
def cli():
print('Scanning for keys...')
keys = get_all_yubikeys(False)
for key in keys:
print("Found {}!".format(key.description))