@@ 74,7 74,7 @@ class HgSync(object):
# Start the new thread:
thread_push.setDaemon(True)
thread_push.start()
-
+
def initialize(self):
"""
Initialize a new repository.
@@ 101,14 101,14 @@ class HgSync(object):
"""
execute_command("cd " + self.local_url + "; hg add " + new_file)
self.commit("Added " + new_file)
-
+
def modify(self, the_file):
"""
Modify a file.
"""
execute_command("cd " + self.local_url + "; hg commit -u " + self.username + " -m 'Updated " + the_file + "'")
self.commit("Updated " + the_file)
-
+
def remove(self, file_to_remove):
"""
Remove a file.
@@ 149,7 149,7 @@ class HgSync(object):
execute_command("cd " + self.local_url + "; hg pull")
execute_command("cd " + self.local_url + "; hg update")
time.sleep(240)
-
+
if __name__ == "__main__":
@@ 54,7 54,7 @@ class PTmp(pyinotify.ProcessEvent):
#self.repo.clone()
self.in_from = ""
-
+
def process_IN_CREATE(self, event):
"""
Called when a file has been created.
@@ 62,7 62,7 @@ class PTmp(pyinotify.ProcessEvent):
if "hg-check" not in event.name:
print "Created: %s " % os.path.join(event.path, event.name)
self.repo.add(os.path.join(event.path, event.name))
-
+
def process_IN_DELETE(self, event):
"""
Called when a file has been deleted.
@@ 70,7 70,7 @@ class PTmp(pyinotify.ProcessEvent):
if "hg-check" not in event.name:
print "Deleted: %s " % os.path.join(event.path, event.name)
self.repo.remove(os.path.join(event.path, event.name))
-
+
def process_IN_MODIFY(self, event):
"""
Called when a file has been modified.
@@ 78,7 78,7 @@ class PTmp(pyinotify.ProcessEvent):
if "hg-check" not in event.name:
print "Modified: %s " % os.path.join(event.path, event.name)
self.repo.modify(os.path.join(event.path, event.name))
-
+
def process_IN_MOVED_FROM(self, event):
"""
Called when a file has been moved from (source).
@@ 113,7 113,7 @@ if __name__ == "__main__":
username = config.get('repo', 'username')
password = config.get('repo', 'password')
-
+
wm = pyinotify.WatchManager()
notifier = pyinotify.Notifier(wm, PTmp("https://" + username + ":" + password + "@" + url, local_url, username))