#!/usr/bin/python3 import os import sys output_size = int(sys.argv[1]) num_blocks = output_size // 256 sys.stderr.write('num_blocks is %d\n' % num_blocks) def give_block(): block_list = [] for i in range(256): block_list.append(bytes([ i ])) return b''.join(block_list) block = give_block() for blockno in range(num_blocks): if blockno % 256 == 0: sys.stderr.write('{}: blockno {:.1f}%\r'.format(sys.argv[0], blockno * 100.0 / num_blocks)) os.write(1, block) sys.stderr.write('\n')