コード例 #1
0
ファイル: controller.py プロジェクト: nuxeo/nuxeo-otg
            for b in self.storage.list_bindings():
                for p in sorted(self.storage.get_states(b).keys()):
                    pairs.append((b, p))
        else:
            for local_folder in local_folders:
                pairs.append(self.split_path(local_folder))
        return pairs

    def refresh(self, local_folders=[], async=True):
        bindings = self.get_bindings_for(local_folders)
        if async:
            # TODO queue a command to synchronizer process
            pass
        else:
            # perform synchronization right away
            for b in bindings:
                sync = Synchronizer(self.storage, binding=b)
                sync.update_local_info(updated_other=False)
                sync.update_remote_info(updated_other=True)

    def synchronize(self, local_folders=[], async=True):
        bindings = self.get_bindings_for(local_folders)
        if async:
            # TODO queue a command to synchronizer process
            pass
        else:
            # perform synchronization right away
            for b in bindings:
                sync = Synchronizer(self.storage, binding=b)
                sync.synchronize_all()
コード例 #2
0
ファイル: main.py プロジェクト: nuxeo/nuxeo-otg
def main():
    home = os.path.join(os.environ['HOME'], ".nuxeo")
    config = ConfigParser.ConfigParser()
    config.read(os.path.join(home, "config.cfg"))

    server = config.get("global", "server")
    username = config.get("global", "username")
    password = config.get("global", "password")
    interval = config.getint("global", "interval")

    local_root = config.get("bindings", "local")
    remote_root = config.get("bindings", "remote")

    storage = Storage(os.path.join(home, "nuxeo.db"))
    local_client = LocalClient(local_root)
    remote_client = RemoteClient(server, username, password, remote_root)

    synchronizer = Synchronizer(storage, local_client, remote_client)

    synchronizer.update_local_info()
    synchronizer.update_remote_info()
    synchronizer.update_local_info()

    while True:
        synchronizer.synchronize_all()
        time.sleep(interval)
        synchronizer.update_remote_info()
        synchronizer.update_local_info()