Created
May 31, 2012 01:33
-
-
Save nathania/2840185 to your computer and use it in GitHub Desktop.
Execute git command from Python script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from subprocess import Popen, PIPE | |
from os import path | |
git_command = ['/usr/bin/git', 'status'] | |
repository = path.dirname('/path/to/dir/') | |
git_query = Popen(git_command, cwd=repository, stdout=PIPE, stderr=PIPE) | |
(git_status, error) = git_query.communicate() | |
if git_query.poll() == 0: | |
# Do stuff |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The link doesn't work anymore, could you please provide another one?