diff options
author | Szczepan Zalega <szczepan@nitrokey.com> | 2018-01-04 20:18:53 +0100 |
---|---|---|
committer | Szczepan Zalega <szczepan@nitrokey.com> | 2018-01-04 20:18:53 +0100 |
commit | d917909036585eabeaa2e2727fca1d3d8cf9d086 (patch) | |
tree | 8fe5a3c09d302a844dea1c61f6c12453d6d9c7e7 /python_bindings_example.py | |
parent | 09f80ac4123a2bc02737f19faecb8f2935599cd5 (diff) | |
parent | 57621cf96960a4e64a25383b50f8876183f632f6 (diff) | |
download | libnitrokey-d917909036585eabeaa2e2727fca1d3d8cf9d086.tar.gz libnitrokey-d917909036585eabeaa2e2727fca1d3d8cf9d086.tar.bz2 |
Merge branch '82-python_example_fix'
Diffstat (limited to 'python_bindings_example.py')
-rwxr-xr-x | python_bindings_example.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/python_bindings_example.py b/python_bindings_example.py index 37b70b8..1740a76 100755 --- a/python_bindings_example.py +++ b/python_bindings_example.py @@ -25,14 +25,18 @@ def get_library(): with open(fp, 'r') as f: declarations = f.readlines() + cnt = 0 a = iter(declarations) for declaration in a: - if declaration.startswith('NK_C_API'): + if declaration.strip().startswith('NK_C_API'): declaration = declaration.replace('NK_C_API', '').strip() - while not ';' in declaration: + while ';' not in declaration: declaration += (next(a)).strip() - #print(declaration) + # print(declaration) ffi.cdef(declaration, override=True) + cnt +=1 + print('Imported {} declarations'.format(cnt)) + C = None import os, sys @@ -68,10 +72,10 @@ a = raw_input() if not a == 'continue': exit() -ADMIN = raw_input('Please enter your admin PIN (empty string uses 12345678)') +ADMIN = raw_input('Please enter your admin PIN (empty string uses 12345678) ') ADMIN = ADMIN or '12345678' # use default if empty string -show_log = raw_input('Should log messages be shown (please write "yes" to enable)?') == 'yes' +show_log = raw_input('Should log messages be shown (please write "yes" to enable)? ') == 'yes' libnitrokey = get_library() libnitrokey.NK_set_debug(show_log) # do not show debug messages |