proc = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE, stdout=
    subprocess.PIPE)
while True:
    output = proc.stdout.readline()
if 'to-check' in output:
    m = re.findall('to-check=(\\d+)/(\\d+)', output)
progress = 100 * (int(m[0][1]) - int(m[0][0])) / total_files
sys.stdout.write('\rDone: ' + str(progress) + '%')
sys.stdout.flush()
if int(m[0][0]) == 0:
    break
print('\rFinished')
How to show the rsync --progress in web browser using DJango?