我已经阅读了很多关于如何获取子流程输出的帖子,但我无法获得显示导入CSV时进度的特定输出:
2017-12-06T21:25:20.197+0100 connected to: localhost
2017-12-06T21:25:23.193+0100 [........................] tfg.test 15.1MB/875MB (1.7%)
2017-12-06T21:25:26.193+0100 [........................] tfg.test 32.0MB/875MB (3.7%)
2017-12-06T21:25:29.193+0100 [#.......................] tfg.test 49.1MB/875MB (5.6%)
2017-12-06T21:25:32.193+0100 [#.......................] tfg.test 63.6MB/875MB (7.3%)
2017-12-06T21:25:35.191+0100 [##......................] tfg.test 83.9MB/875MB (9.6%)
2017-12-06T21:25:38.189+0100 [##......................] tfg.test 104MB/875MB (11.9%)
2017-12-06T21:25:41.189+0100 [###.....................] tfg.test 122MB/875MB (13.9%)
2017-12-06T21:25:44.194+0100 [###.....................] tfg.test 141MB/875MB (16.1%)
2017-12-06T21:25:47.191+0100 [####....................] tfg.test 160MB/875MB (18.2%)
2017-12-06T21:25:50.193+0100 [####....................] tfg.test 179MB/875MB (20.5%)
2017-12-06T21:25:53.192+0100 [#####...................] tfg.test 197MB/875MB (22.5%)
2017-12-06T21:25:56.193+0100 [#####...................] tfg.test 214MB/875MB (24.4%)
2017-12-06T21:25:59.193+0100 [######..................] tfg.test 231MB/875MB (26.4%)
我运行其中一个子进程指令,但是当获得outoput时,我获得了''b''b''b''b''b''b ....
p = check_output(['mongoimport', '-d', 'tfg', '-c', 'myCol', '--type', 'csv', '--file', '/col.csv', '--headerline'])
p = subprocess.Popen(['mongoimport', '-d', 'tfg', '-c', 'myCol', '--type', 'csv', '--file', '/col.csv', '--headerline'], stdout=subprocess.PIPE)