Резултатът от Popen
stdout не е същият като изпълнение на командата от Shell или използване на os.system
:
cmd = ['git', 'diff', commitHash, '--stat']
print Popen(cmd, stdout=PIPE).stdout.read().strip()
os.system(' '.join(cmd))
Резултатът от Popen
:
src/tech/dalvik/sidebar.md | 10 -
.../encryption/android_crypto_implementation.md | 359 --
src/tech/encryption/index.md | 22 -
src/tech/encryption/sidebar.md | 9 -
src/tech/index.md | 58 -
src/tech/nfc/index.md | 25 -
src/tech/nfc/sidebar.md | 7 -
src/tech/sidebar.md | 5 -
templates/footer | 3 +-
templates/includes | 2 +-
templates/sidebar | 2 +-
257 files changed, 32311 insertions(+), 11358 deletions(-)
Изходът от os.system
(същият като стартиране от Shell)
src/tech/dalvik/sidebar.md | 10 -
src/tech/encryption/android_crypto_implementation.md | 359 ---------
src/tech/encryption/index.md | 22 -
src/tech/encryption/sidebar.md | 9 -
src/tech/index.md | 58 --
src/tech/nfc/index.md | 25 -
src/tech/nfc/sidebar.md | 7 -
src/tech/sidebar.md | 5 -
templates/footer | 3 +-
templates/includes | 2 +-
templates/sidebar | 2 +-
257 files changed, 32311 insertions(+), 11358 deletions(-)
Как мога да накарам subprocess.Popen
да работи точно като os.system
?
Намерих подобен въпрос тук: Stdout, уловен от канал в Python, е съкратен, но настройката на променливата на средата LANG
изглежда не работи.
Благодаря!