Created
January 19, 2014 10:51
-
-
Save kazufusa/8503209 to your computer and use it in GitHub Desktop.
subprocess.Popenでgit ref: http://qiita.com/kazufusa/items/d3da5354be5d75926a5b
This file contains 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
# vim: set fileencoding=utf-8 : | |
# Created: 2014-01-19 | |
# Git submodule update within python subprocess | |
import os | |
import subprocess | |
GIT = "git" | |
SUBMODULE = "submodule" | |
FOREACH = "foreach" | |
class Git(object): | |
def __init__(self): | |
self._dir = "" | |
pass | |
@property | |
def dir(self): | |
return self._dir | |
@dir.setter | |
def dir(self, dir): | |
self._dir = dir | |
def submodule_update(self): | |
pr = subprocess.Popen([GIT, SUBMODULE, FOREACH, 'git checkout master; git pull'], | |
cwd=os.path.dirname(self.dir), | |
stdout=subprocess.PIPE, | |
stderr=subprocess.PIPE, | |
shell=False) | |
(out, error) = pr.communicate() | |
return out, error | |
if __name__ == "__main__": | |
APP_ROOT = os.path.dirname(os.path.abspath(__file__)) | |
dir = os.path.join(APP_ROOT, ".git") | |
git = Git() | |
git.dir = dir | |
git.submodule_update() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment