thespacedoctor
3/13/2018 - 9:40 AM

[Sync Github Repo Wikis Between Github and Local Filesystem] #wiki #github #sync

[Sync Github Repo Wikis Between Github and Local Filesystem] #wiki #github #sync

#!/usr/local/bin/python
# encoding: utf-8
"""
github-wiki-sync.py
===========================
:Summary:
    Sync github wikis between mac and github

:Author:
    David Young

:Date Created:
    November 10, 2015
"""
################# GLOBAL IMPORTS ####################
import sys
import os
from subprocess import Popen, PIPE, STDOUT


def main(arguments=None):
    """
    *The main function used when ``github-wiki-sync.py`` is run as a single script from the cl*
    """

    basePath = "/Users/Dave/Dropbox/notes"
    for d in os.listdir(basePath):
        if os.path.isdir(os.path.join(basePath, d)):
            if d[-5:] == ".wiki":
                repoPath = os.path.join(basePath, d)
                cmd = """cd %(repoPath)s && git add . && git commit -m 'auto added' && git pull && git push""" % locals()
                p = Popen(cmd, stdout=PIPE, stdin=PIPE, shell=True)
                output = p.communicate()[0]
                print output

    return

if __name__ == '__main__':
    main()