c3po/mod/communicator.py
def git_push(git_message=None, git_repository=None, git_branch=None,
             locale_root=None):
    """
    Pushes specified directory to git remote
    :param git_message: commit message
    :param git_repository: repository address
    :param git_branch: git branch
    :param locale_root: path to locale root folder containing directories
                        with languages
    :return: tuple stdout, stderr of completed command
    """
    if git_message is None:
        git_message = settings.GIT_MESSAGE
    if git_repository is None:
        git_repository = settings.GIT_REPOSITORY
    if git_branch is None:
        git_branch = settings.GIT_BRANCH
    if locale_root is None:
        locale_root = settings.LOCALE_ROOT

    try:
        subprocess.check_call(['git', 'checkout', git_branch])
    except subprocess.CalledProcessError:
        try:
            subprocess.check_call(['git', 'checkout', '-b', git_branch])
        except subprocess.CalledProcessError as e:
            raise PODocsError(e)

    try:
        subprocess.check_call(['git', 'ls-remote', git_repository])
    except subprocess.CalledProcessError:
        try:
            subprocess.check_call(['git', 'remote', 'add', 'po_translator',
                                   git_repository])
        except subprocess.CalledProcessError as e:
            raise PODocsError(e)

    commands = 'git add ' + locale_root + \
               ' && git commit -m "' + git_message + '"' + \
               ' && git push po_translator ' + git_branch + ':' + git_branch
    proc = Popen(commands, shell=True, stdout=PIPE, stderr=PIPE)
    stdout, stderr = proc.communicate()

    return stdout, stderr
def git_push(git_message=None, git_repository=None, git_branch=None,
             locale_root=None):
    """
    Pushes specified directory to git remote
    :param git_message: commit message
    :param git_repository: repository address
    :param git_branch: git branch
    :param locale_root: path to locale root folder containing directories
                        with languages
    :return: tuple stdout, stderr of completed command
    """
    if git_message is None:
        git_message = settings.GIT_MESSAGE
    if git_repository is None:
        git_repository = settings.GIT_REPOSITORY
    if git_branch is None:
        git_branch = settings.GIT_BRANCH
    if locale_root is None:
        locale_root = settings.LOCALE_ROOT

    try:
        subprocess.check_call(['git', 'checkout', git_branch])
    except subprocess.CalledProcessError:
        try:
            subprocess.check_call(['git', 'checkout', '-b', git_branch])
        except subprocess.CalledProcessError as e:
            raise PODocsError(e)

    try:
        subprocess.check_call(['git', 'ls-remote', git_repository])
    except subprocess.CalledProcessError:
        try:
            subprocess.check_call(['git', 'remote', 'add', 'po_translator',
                                   git_repository])
        except subprocess.CalledProcessError as e:
            raise PODocsError(e)

    commands = 'git add ' + locale_root + \
               ' && git commit -m "' + git_message + '"' + \
               ' && git push po_translator ' + git_branch + ':' + git_branch
    proc = Popen(commands, shell=True, stdout=PIPE, stderr=PIPE)
    stdout, stderr = proc.communicate()

    return stdout, stderr
Pushes specified directory to git remote
    :param git_message: commit message
    :param git_repository: repository address
    :param git_branch: git branch
    :param locale_root: path to locale root folder containing directories
                        with languages
    :return: tuple stdout, stderr of completed command