An easier solution would be to use the Python subprocess
module to call git. In your case, this would pull the latest code and build:
import subprocess
subprocess.call(["git", "pull"])
subprocess.call(["make"])
subprocess.call(["make", "test"])
Docs:
- subprocess – Python 2.x
- subprocess – Python 3.x