I am trying to save the output of
git remote show origin
with
tempf = open('.tmp', 'w+')
tempf2 = open('.tmp2', 'w+')
subprocess.Popen(["git", "remote", "show", "origin"], stdout=tempf, stderr=tempf2)
tempf.close()
tempf2.close()
output = open('.tmp', 'r')
gitoutput = output.read()
and later parse the output with a regex.
However, the code above keeps returning None for gitoutput.
Is there something that I am missing? I am fairly confused as applying .seek(0) does not change the output and running cat .tmp shows the correct contents.
EDIT: stderr is also captured (stderr=tempf2) and thrown away as the git server produces unwanted output to the command line when running the script.
subprocess.check_callinstead