Python Example
An example Python script is included that demonstrates how to open a log file and extract some information from it. It is installed in \Log File Examples\Python. The script is written for Python 3, but could be easily modified to run on Python 2.
The script takes the filename of a log file as its argument and prints some information about the test runs contained inside it.
The example program uses the standard zipfile module:
try: with zipfile.ZipFile(xjlog_filepath) as xjlog_file: # extract data from the log file except zipfile.BadZipFile: print("{} is not a valid .xjlog file.".format(xjlog_filepath))
It then uses the ElementTree XML module to parse the XML from the file inside the zip file. This snippet of code demonstrates parsing the contents of Info.xml that was opened above and then extracting the number of test runs that are in the log file:
try: info_file = xjlog_file.getinfo("Info.xml"); with xjlog_file.open(info_file.filename) as info: root = ET.fromstring(info.read()) return int(root.find("TestRunCount").text) except: print("Error trying to open Info.xml in the log file.") raise
The test run XML is parsed in a similar way.
Sample Output
This is some sample output from the program with a log file from the XJDemo board that contains three test runs:
Test Run 1: Passed Tests Passed: 22 NEW_SERIAL_NUMBER, CheckChain, CONNTEST, IC5.Test, ProgrammedFlashCheck, IC3.TestDestructive, IC7.Test, EEPROM_PIO_Test, Y1.TestOscillator, Y1FrequencyTest, IC6.IIC_CheckPresent, ADC_Test, SW1.Test, D1.Test, D2.Test, D3.Test, D4.Test, EraseIC3, ProgramIC3, VerifyIC3 (Post programming), RunStaplFile, WriteSerialNumber Tests Failed: 0 Tests Skipped: 2 Test Run 2: Failed Tests Passed: 0 Tests Failed: 1 NEW_SERIAL_NUMBER (388ms) Tests Skipped: 0 Test Run 3: Stopped Tests Passed: 7 NEW_SERIAL_NUMBER, CheckChain, CONNTEST, IC5.Test, ProgrammedFlashCheck, IC3.TestNonDestructive, IC7.Test Tests Failed: 0 Tests Skipped: 1 Testing was interrupted during the test EEPROM_PIO_Test
XJTAG v4.1.100