Runtime functions¶
-
echo
(message, log_level=8)¶ Log the message argument depending on the logging level
param str message: the message to log.
param int log_level: the logging level of this message
The logging level could be:
- DEBUG_LEVEL (0x04): All logging messages are displayed
- INFO_LEVEL (0x08): Information and error logging messages are displayed
- ERROR_LEVEL (0x10): Error logging messages are displayed
# echo the message only if the DEBUG_LEVEL is set echo("my message", DEBUG_LEVEL)
-
get_key_in_repository
(keysetversion, key_identifier=None)¶ Returns the list of Tuple (key value/Key type) stored into the off card key repository regarding their key version number and eventually their key identifier.
Parameters: - keysetversion (str) – the key set version.
- key_identifier (str) – the key identifier.
Returns list key_list: A list of Tuple (key_version_number, key_id, key_type, key_value) matching the key version number
-
get_version
()¶ Returns current PyGP API version
-
get_payload_list
()¶ Returns the list of payload apdu.
Returns: list payload_list: the list of apdu
-
get_total_execution_time
()¶ Returns the total execution time.
Returns: time in second.
-
last_response
()¶ Returns the last card response as a haxadecimal string.
Returns: str response: the last APDU card response. Note
The response doesn’t contain status word. Use
last_status()
to get it.
-
last_status
()¶ Returns the last card status word as a haxadecimal string.
Returns: str response: the last APDU status word.
-
set_log_mode
(loggingMode, file_path=None)¶ Manages the logging capabilities.
Parameters: - loggingMode (int) –
a mask value to configure logging capabilities
The logging mode could be:
- NONE (0x00): No log
- CONSOLE_TRACE (0x01): Logging output is sent to sys.stdout, sys.stderr console.
- FILE_TRACE (0x02): Logging output is sent to a file specified by the file parameter.
- If you didn’t set file name then [script file name].log file will be created.
The logging level could be:
- DEBUG_LEVEL (0x04): All logging messages are displayed
- INFO_LEVEL (0x08): Information and error logging messages are displayed
- ERROR_LEVEL (0x10): Error logging messages are displayed
The logging option could be:
- APDU (0x20): APDU exchanges are displayed
- APDU_MNGT (0x40): APDU exchanges due to the protocol (formelly T=0 protocol) are displayed
- APDU_TIMING (0x80): APDU exchanges timing are displayed
- file_path (str) – the path of the logging file if the logging mode is set to FILE_TRACE
# set the logging mode to a file with debug logging level set_log_mode(FILE_TRACE|DEBUG_LEVEL, "C:/log/myLoggingFile.txt") # set the logging mode to a file with debug logging level, but without filename set_log_mode(FILE_TRACE|DEBUG_LEVEL) # set the logging mode to the console only with information logging level and APDU exchanges set_log_mode(CONSOLE_TRACE|INFO_LEVEL|APDU)
- loggingMode (int) –
-
set_payload_mode
(activate)¶ Allows to store all apdu to send into a list in place of sending them to the card. The list containing apdus could be retreive by using the :func get_payload_list
Parameters: activate (bool) – Activate the payload mode
-
set_key
(*args)¶ Put key definition into the off card key repository.
Parameters: args (str) – key defined using a specific format: “KEY_VERSION_NUMBER/KET_ID/KEY_TYPE/KEY_VALUE” Note
KEY_TYPE value could be: DES-ECB, DES-CBC, AES, RSA-PRIV, RSA-PUB
Note
If a key defined by its key version number is already present into the off card key repository, the new value will replace the old one.
-
set_start_timing
()¶ Start to measure APDU transaction time. It will add the time consumption of each command.
-
sleep
(milliseconds)¶ Delay execution for a given amount of time in millisecond unit.
Parameters: milliseconds (int) – a number of milliseconds to delay execution process
-
stop_on_error
(value)¶ Allows to stop the execution if an error occured.
Parameters: value (bool) – True if execution should be stopped, False otherwise