I am currently working on GIT automation using sub process. This is new for me . Trying out a basic status call as shown below, but keep getting error.
from subprocess import Popen, PIPE
import os
import subprocess
PIPE = subprocess.PIPE
branch = "C:/git-repos/Myfolder"
process = subprocess.Popen(["git status", branch], stdout=PIPE, stderr=PIPE)
stdoutput, stderroutput = process.communicate()
if 'fatal' in stdoutput:print "error"
else:print "Successful"
ERROR message::
Traceback (most recent call last):
File "gitscript.py", line 9, in <module>
process = subprocess.Popen(["git status", branch], stdout=PIPE, stderr=PIPE)
File "C:\Python25\Lib\subprocess.py",
line 594, in __init__
errread, errwrite)
File "C:\Python25\Lib\subprocess.py",
line 818, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified
What am I doing wrong?. Note: Myfolder is a local GIT repo. It is NOT a clone of any master repo.
Updated my question after following below comments::
process = subprocess.Popen(["git status", branch], stdout=PIPE, stderr=PIPE, shell=True)
stdoutput, stderroutput = process.communicate()
if 'fatal' in stderroutput:print "error"
else:print "Successful"
1) The output is "Successful" . Stdout print shows blank. while the command(git status) on bash works fine prints out the status.
2) As part of project I have to use Python25, Windows and GIT version is 1.9.
3) Since subprocess did not work . I tried to install Gitpython. Installation does not work for python25. "setup.py" file does not list python25 and keeps throwing error on missing import files.
Request for any ideas or suggestion on how to approach this issue. With current environment setup can I achieve automation using python?
Help Please !