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 return entry
def sync(self, arg): 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": if arg == "json":
exporters.to_json(self, self.config['sync_folder'] + "journal.json") exporters.to_json(self, self.config['sync_folder'] + "journal.json")
elif arg == "md": elif arg == "md":
@ -285,12 +287,12 @@ class Journal(object):
exporters.to_txt(self, self.config['sync_folder'] + "journal.txt") exporters.to_txt(self, self.config['sync_folder'] + "journal.txt")
elif arg == "files": elif arg == "files":
exporters.to_files(self, self.config['sync_folder'] + "*.txt") exporters.to_files(self, self.config['sync_folder'] + "*.txt")
os.chdir(self.config['sync_folder']) os.chdir(self.config['sync_folder']) # change current folder to the sync_folder
subprocess.call(["git", "pull"]) subprocess.call(["git", "pull"]) # calls git pull to retrieve any changes
subprocess.call(["git", "add", "."]) 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')) message = "Site update at " + str(datetime.now().strftime('%Y-%m-%d %H:%M:%S')) # creates a new commit
subprocess.call(["git", "commit", "-m", message]) subprocess.call(["git", "commit", "-m", message]) # commits the changes
subprocess.call(["git", "push"]) subprocess.call(["git", "push"]) # calls git push to make the new changes
return "journal synced to " + self.config['sync_folder'] return "journal synced to " + self.config['sync_folder']