@@ 50,10 50,10 @@ class PTmp(pyinotify.ProcessEvent):
def __init__(self, url, local_url, username):
"""
"""
- self.repo = hgsync.HgSync(url, local_url, username)
- #self.repo.clone()
-
- self.in_from = ""
+ if type_repo == "hg":
+ self.repo = hgsync.HgSync(url, local_url, username)
+ #self.repo.clone()
+ self.in_from = ""
def process_IN_CREATE(self, event):
"""
@@ 97,6 97,21 @@ class PTmp(pyinotify.ProcessEvent):
self.in_from = ""
+def start_watcher(type_repo, username, password, url, local_url):
+ """
+ Start a watcher. This function is called in a separate thread.
+ """
+ wm = pyinotify.WatchManager()
+ notifier = pyinotify.Notifier(wm, PTmp(type_repo, "https://" + username + ":" + password + "@" + url, local_url, username))
+ wdd = wm.add_watch((local_url) , mask, rec=True, auto_add=True, exclude_filter=excl)
+ while True:
+ try:
+ notifier.process_events()
+ if notifier.check_events():
+ notifier.read_events()
+ except KeyboardInterrupt:
+ notifier.stop()
+ break
if __name__ == "__main__":
@@ 114,17 129,8 @@ if __name__ == "__main__":
password = config.get('repo', 'password')
- wm = pyinotify.WatchManager()
- notifier = pyinotify.Notifier(wm, PTmp("https://" + username + ":" + password + "@" + url, local_url, username))
-
- wdd = wm.add_watch((local_url) , mask, rec=True, auto_add=True, exclude_filter=excl)
-
-
- while True:
- try:
- notifier.process_events()
- if notifier.check_events():
- notifier.read_events()
- except KeyboardInterrupt:
- notifier.stop()
- break
No newline at end of file
+ # Launch a new thread for the repository to watch
+ thread = threading.Thread(None, start_watcher, None, (username, password, url, local_url))
+ thread = threading.Thread(None, start_watcher, None, (type_repo, username, password, url, local_url))
+ #thread.setDaemon(True)
+ thread.start()
No newline at end of file