serialdata/sr-info.py

Thu, 07 Oct 2021 21:05:13 +0200

author
David Douard <david.douard@sdfa3.org>
date
Thu, 07 Oct 2021 21:05:13 +0200
changeset 67
e19b4147caa9
parent 23
daf26b083899
permissions
-rw-r--r--

Reduce the sleep time of the send_pending_key thread to 1ms

to get a chance of sending a keycode when the CPU flood the FP with DSP
messages (e.g. after the last 'Last-N' value).

import zipfile
import configparser


def extract_metadata(fname):
    cfg = configparser.ConfigParser()
    with zipfile.ZipFile(fname) as zf:
        mdata = zf.open('metadata').read()
    cfg.read_string(mdata.decode())
    return cfg


def print_metadata(mdata):
    for kv in mdata['global'].items():
        print('%s: %s' % kv)
    for device, cfg in mdata.items():
        if device in ('global', 'DEFAULT'):
            continue
        print('%s:' % device)
        for kv in cfg.items():
            print('  %s: %s' % kv)


if __name__ == '__main__':
    import sys
    for fn in sys.argv[1:]:
        print_metadata(extract_metadata(fn))

mercurial