summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan@nitrokey.com>2018-01-04 20:18:53 +0100
committerSzczepan Zalega <szczepan@nitrokey.com>2018-01-04 20:18:53 +0100
commitd917909036585eabeaa2e2727fca1d3d8cf9d086 (patch)
tree8fe5a3c09d302a844dea1c61f6c12453d6d9c7e7
parent09f80ac4123a2bc02737f19faecb8f2935599cd5 (diff)
parent57621cf96960a4e64a25383b50f8876183f632f6 (diff)
downloadlibnitrokey-d917909036585eabeaa2e2727fca1d3d8cf9d086.tar.gz
libnitrokey-d917909036585eabeaa2e2727fca1d3d8cf9d086.tar.bz2
Merge branch '82-python_example_fix'
-rwxr-xr-xpython_bindings_example.py14
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