def _on_bms_message_receive(self, message):
        # parse message and update directory
        if not message or len(message) <= 0:
            return

        msg = json.loads(message)
        operation = msg.get("operation")
        if operation:
            if operation in ["collection.add", "collection.rm", "data-object.add", "data-object.rm", "data-object.mod"]:
                path = msg.get("path")
                if path:
                    parent_path = os.path.dirname(path)
                    entries = self.irods.listStats(parent_path)
                    stats = []
                    for e in entries:
                        stat = abstract_fs.fs_stat(directory=e.directory, 
                                                   path=e.path,
                                                   name=e.name, 
                                                   size=e.size,
                                                   checksum=e.checksum,
                                                   create_time=e.create_time,
                                                   modify_time=e.modify_time)
                        stats.append(stat)
                    self.dataset_tracker.updateDirectory(path=parent_path, entries=stats)

            elif operation in ["collection.mv", "data-object.mv"]:
                old_path = msg.get("old-path")
                old_parent_path = None
                if old_path:
                    old_parent_path = os.path.dirname(old_path)
                    entries = self.irods.listStats(old_parent_path)
                    stats = []
                    for e in entries:
                        stat = abstract_fs.fs_stat(directory=e.directory, 
                                                   path=e.path,
                                                   name=e.name, 
                                                   size=e.size,
                                                   checksum=e.checksum,
                                                   create_time=e.create_time,
                                                   modify_time=e.modify_time)
                        stats.append(stat)
                    self.dataset_tracker.updateDirectory(path=old_parent_path, entries=stats)

                new_path = msg.get("new-path")
                if new_path:
                    new_parent_path = os.path.dirname(new_path)
                    if new_parent_path != old_parent_path:
                        entries = self.irods.listStats(new_parent_path)
                        stats = []
                        for e in entries:
                            stat = abstract_fs.fs_stat(directory=e.directory, 
                                                       path=e.path,
                                                       name=e.name, 
                                                       size=e.size,
                                                       checksum=e.checksum,
                                                       create_time=e.create_time,
                                                       modify_time=e.modify_time)
                            stats.append(stat)
                        self.dataset_tracker.updateDirectory(path=new_parent_path, entries=stats)
Esempio n. 2
0
 def _on_request_update(self, entry):
     entries = self.irods.listStats(entry.path)
     stats = []
     for e in entries:
         stat = abstract_fs.fs_stat(directory=e.directory, 
                                    path=e.path,
                                    name=e.name, 
                                    size=e.size,
                                    checksum=e.checksum,
                                    create_time=e.create_time,
                                    modify_time=e.modify_time)
         stats.append(stat)
     self.dataset_tracker.updateDirectory(path=entry.path, entries=stats)
Esempio n. 3
0
    def connect(self, scan_dataset=True):
        self.irods.connect()

        if scan_dataset:
            # add initial dataset
            dataset_root = self.dataset_tracker.getRootPath()
            entries = self.irods.listStats(dataset_root)
            stats = []
            for entry in entries:
                stat = abstract_fs.fs_stat(directory=entry.directory, 
                                           path=entry.path,
                                           name=entry.name, 
                                           size=entry.size,
                                           checksum=entry.checksum,
                                           create_time=entry.create_time,
                                           modify_time=entry.modify_time)
                stats.append(stat)
            self.dataset_tracker.updateDirectory(path=dataset_root, entries=stats)