0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

subprocess.Popenでgit

Posted at
git_submodule_update.py
# 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()
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?