我有这个linux命令:
rsync -avz --info=progress2 source:/file /destination
我在 Python 中这样使用过:
proc = subprocess.Popen(['sshpass', '-p', password, 'rsync', '-avz', '--info=progress2', source12, destination],
stderr=subprocess.PIPE, stdout=subprocess.PIPE).communicate()[0]
这会将输出和进度存储在 proc 变量中,如下所示:
receiving incremental file list
rathi/
rathi/20090209.02s1.1_sequence.txt.gz
209,398,969 27% 11.95MB/s 0:00:45
我只想从上面的行中提取进度百分比。我想每 1 分钟检查一次变量并提取更新后的百分比。对于解析我认为可以使用re
module. 我怎样才能达到我的结果?谢谢