build_gcov_files.py
38 lines
| 1013 B
| text/x-python
|
PythonLexer
/ libgcov / build_gcov_files.py
r387 | #!/usr/bin/env python3 | |||
__author__ = "Alexis Jeandet" | ||||
__copyright__ = "Copyright 2018, Laboratory of Plasma Physics" | ||||
__credits__ = [] | ||||
__license__ = "GPLv2" | ||||
__version__ = "1.0.0" | ||||
__maintainer__ = "Alexis Jeandet" | ||||
__email__ = "alexis.jeandet@member.fsf.org" | ||||
__status__ = "Development" | ||||
import time | ||||
import sys | ||||
import os | ||||
import serial | ||||
import argparse | ||||
from datetime import datetime | ||||
parser = argparse.ArgumentParser() | ||||
parser.add_argument("-f", "--gcov-file", help="Gcov output file generated by record_lfr_console.py") | ||||
args = parser.parse_args() | ||||
def main(): | ||||
with open(args.gcov_file,'r') as gcov: | ||||
for line in gcov.readlines(): | ||||
head,dest_file,data = line.split(',') | ||||
if head == '_GCOV_': | ||||
print(f"Writing {dest_file}\n") | ||||
with open(dest_file,'wb') as gcda_file: | ||||
gcda_file.write(bytes([int(''.join(value),16) for value in zip(data[::2],data[1::2]) ])) | ||||
else: | ||||
raise | ||||
if __name__ == "__main__": | ||||
main() | ||||