1import subprocess
2PIPE = subprocess.PIPE
3branch = 'my_branch'
4
5process = subprocess.Popen(['git', 'pull', branch], stdout=PIPE, stderr=PIPE)
6stdoutput, stderroutput = process.communicate()
7
8if 'fatal' in stdoutput:
9 # Handle error case
10else:
11 # Success!
12