Skip to content

Commit

Permalink
Simple handle in Windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
iWoz committed Dec 14, 2017
1 parent 487cd62 commit 356ea90
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions file_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,16 @@
finally:
f.close()

# get filename without upper directory
def path_leaf(path):
head, tail = ntpath.split(path)
return tail or ntpath.basename(head)

class FileChangeHandler(FileSystemEventHandler):
def on_modified(self, event):
src_path = event.src_path.replace('\\','/')
if src_path in SYNC_FILE_LIST:
copy(src_path, DIR_FOR_GIT)
os.chdir(DIR_FOR_GIT)
git_add_cmd = "git add -A"
git_commit_cmd = "git commit -m " + re.escape("Update "+path_leaf(src_path))
git_commit_cmd = "git commit -m " + re.escape("Update "+os.path.basename(src_path))
if platform.system() == "Windows":
git_commit_cmd = "git commit -m " + re.escape("Update_"+path_leaf(src_path))
git_commit_cmd = "git commit -m Update."
git_pull_cmd = "git pull origin master"
git_push_cmd = "git push origin master"
call(
Expand Down

0 comments on commit 356ea90

Please sign in to comment.