Commits

Cédric Bonhomme committed 9d15101

The local URL of the repository is now in the configuration file and used by the synchronization class.

  • Participants
  • Parent commits cb0a1fe

Comments (0)

Files changed (3)

balloon.cfg-sample

 [repo]
 type = hg
-name = test-balloon
+local_url = /home/cedric/balloon/test-balloon
 url = bitbucket.org/cedricbonhomme/test-balloon
 username = cedricbonhomme
 password = ***
         """
         """
         self.locker.acquire()
-        execute_command("cd test-balloon; hg commit -u " + self.username + " -m '" + message + "'")
+        execute_command("cd " + self.local_url + "; hg commit -u " + self.username + " -m '" + message + "'")
         self.nb_commit += 1
         self.locker.release()
 
         """
         Add new_file to the list of tracked files.
         """
-        execute_command("cd test-balloon; hg add " + new_file)
+        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 test-balloon; hg commit -u " + self.username + " -m 'Updated " + the_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.
         """
-        execute_command("cd test-balloon; hg remove " + file_to_remove)
+        execute_command("cd " + self.local_url + "; hg remove " + file_to_remove)
         self.commit("Removed " + file_to_remove)
 
     def rename(self, file_from, file_to):
         while True:
             time.sleep(1)
             if self.nb_commit == 5:
-                execute_command("cd test-balloon; hg push")
+                execute_command("cd " + self.local_url + "; hg push")
                 self.nb_commit = 0
 
     def push(self):
         """
         Push changes and set the number of commits to zero.
         """
-        execute_command("cd test-balloon; hg push")
+        execute_command("cd " + self.local_url + "; hg push")
         self.nb_commit = 0
 
     def pull_loop(self):
         Pull from the remote repository.
         """
         while True:
-            execute_command("cd test-balloon; hg pull")
-            execute_command("cd test-balloon; hg update")
+            execute_command("cd " + self.local_url + "; hg pull")
+            execute_command("cd " + self.local_url + "; hg update")
             time.sleep(240)
         
 
     except:
         pass
     type_repo = config.get('repo', 'type')
-    name = config.get('repo', 'name')
+    local_url = config.get('repo', 'local_url')
     url = config.get('repo', 'url')
     username = config.get('repo', 'username')
     password = config.get('repo', 'password')
 
     
     wm = pyinotify.WatchManager()
-    notifier = pyinotify.Notifier(wm, PTmp("https://" + username + ":" + password + "@" + url, ".", username))
+    notifier = pyinotify.Notifier(wm, PTmp("https://" + username + ":" + password + "@" + url, local_url, username))
 
-    wdd = wm.add_watch(os.path.join(os.getcwd(), name) , mask, rec=True, auto_add=True, exclude_filter=excl)
+    wdd = wm.add_watch((local_url) , mask, rec=True, auto_add=True, exclude_filter=excl)
 
 
     while True: