Python: os.system("git clone") does not shows any output from command

See following project

I’m running git clone manually (want to restore original file modification time), and it looks like working, but for some reason I don’t see any output from executed command, same kind of output can be observed successfully in linux. I have even tried to update python to newer version or use something else that os.system, but result is the same.

Not sure if it’s the same problem or not -
python script, output = os.popen(’"{}" && set’.format(vsvars_path)).read()

result in nothing gets readed out from child process - when I run same script locally - works correctly in my windows 10.

It looks like stderr is shown in Windows, but after the build log rather than inline as it should.

In your case, that would be:

C:\dev1\test_travis_ci\files\git\home\travis\build\cppreflect\out: No such file or directory
C:\dev1\test_travis_ci\files\git\home\travis\build\cppreflect\out: unknown file type

Nope, it does not seems to be a problem. I have now also redirected second stream, but for linux I can see output, for windows not. See

Probably something fishy with your command. Note that the string literal is subject to processing by Python, then whatever is passed to subprocess.Popen(shell=True) is subject to processing by cmd.exe. Since bash and cmd have different syntax, it’s quite possible that what is okay for bash results in something bogus for cmd.

My test clearly show where each type of output goes: – so I can say with confidence that both stdout an stderr are indeed logged.

Try executing the same command directly and/or constructing the argument list by hand with shell=False. Popen(shell=True) is not recommended for use specifically because of this unpredictable and OS- and environment-specific behavior.

Doubt it. I have other commands there as well - for example to cmake, they work fine. (using same python function call)
Only git command does not displays output correctly.

1 Like