2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-22 09:32:21 +00:00
confluent/misc/cblreader.py

29 lines
713 B
Python
Raw Normal View History

2019-03-29 15:17:05 +00:00
import struct
import sys
import time
def main(binfile, txtfile):
binf = open(binfile, 'r')
txtf = open(txtfile, 'r')
record = binf.read(16)
while record:
recs = struct.unpack('!BBIHIBBH', record)
offset = recs[2]
size = recs[3]
tstamp = recs[4]
tstamp = time.strftime('%m/%d %H:%M:%S ', time.localtime(tstamp))
txtf.seek(offset)
currdata = txtf.read(size)
sys.stdout.write(currdata)
sys.stdout.write('\x1b]0;{0}\x07'.format(tstamp))
sys.stdout.flush()
raw_input()
record = binf.read(16)
if __name__ == '__main__':
binfile = sys.argv[1]
txtfile = sys.argv[2]
main(binfile, txtfile)