Added doc of sync

Signed-off-by: Aniket Pant <me@aniketpant.com>
This commit is contained in:
Aniket Pant 2013-04-14 14:59:03 +05:30
parent 0de0c28ea8
commit a6b5619e68

View file

@ -277,6 +277,8 @@ class Journal(object):
return entry
def sync(self, arg):
"""Syncs journal on the basis of supplied argument.
Takes json, md, txt, files as arguments and syncs to sync_folder"""
if arg == "json":
exporters.to_json(self, self.config['sync_folder'] + "journal.json")
elif arg == "md":
@ -285,12 +287,12 @@ class Journal(object):
exporters.to_txt(self, self.config['sync_folder'] + "journal.txt")
elif arg == "files":
exporters.to_files(self, self.config['sync_folder'] + "*.txt")
os.chdir(self.config['sync_folder'])
subprocess.call(["git", "pull"])
subprocess.call(["git", "add", "."])
message = "Site update at " + str(datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
subprocess.call(["git", "commit", "-m", message])
subprocess.call(["git", "push"])
os.chdir(self.config['sync_folder']) # change current folder to the sync_folder
subprocess.call(["git", "pull"]) # calls git pull to retrieve any changes
subprocess.call(["git", "add", "."]) # adds the new files to the repository
message = "Site update at " + str(datetime.now().strftime('%Y-%m-%d %H:%M:%S')) # creates a new commit
subprocess.call(["git", "commit", "-m", message]) # commits the changes
subprocess.call(["git", "push"]) # calls git push to make the new changes
return "journal synced to " + self.config['sync_folder']