Skip to content

Commit

Permalink
Update example so it works under Python 3.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kami committed Nov 9, 2013
1 parent 43d964f commit 8448a83
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions demo/example.py
@@ -1,6 +1,11 @@
import sys

from yubico_client import Yubico
from yubico_client import yubico_exceptions
from yubico_client.py3 import PY3

if PY3:
raw_input = input

client_id = raw_input('Enter your client id: ')
secret_key = raw_input('Enter your secret key (optional): ')
Expand All @@ -19,17 +24,20 @@

try:
status = client.verify(token)
except yubico_exceptions.InvalidClientIdError, e:
print 'Client with id %s does not exist' % (e.client_id)
except yubico_exceptions.InvalidClientIdError:
e = sys.exc_info()[1]
print('Client with id %s does not exist' % (e.client_id))
sys.exit(1)
except yubico_exceptions.SignatureVerificationError:
print 'Signature verification failed'
print('Signature verification failed')
sys.exit(1)
except yubico_exceptions.StatusCodeError, e:
print 'Negative status code was returned: %s' % (e.status_code)
except yubico_exceptions.StatusCodeError:
e = sys.exc_info()[1]
print('Negative status code was returned: %s' % (e.status_code))
sys.exit(1)

if status:
print 'Success, the provided OTP is valid'
print('Success, the provided OTP is valid')
else:
print 'No response from the servers or received other negative status code'
print('No response from the servers or received other negative '
'status code')

0 comments on commit 8448a83

Please sign in to comment.