コード例 #1
0
 def on_volume_changed(self, volume_monitor: Gio.VolumeMonitor,
                       gio_volume: Gio.Volume):
     logger.debug(
         "in on_volume_changed. volume: %s",
         gio_volume.get_identifier(Gio.VOLUME_IDENTIFIER_KIND_UNIX_DEVICE))
     try:
         volume = Volume(self, gio_volume)
         if volume.is_tcrypt:
             self.update_volume(volume)
     except UdisksObjectNotFoundError:
         self.remove_volume(Volume(self, gio_volume, with_udisks=False))
コード例 #2
0
    def add(self, volume: Volume):
        if volume in self.volumes:
            self.update(volume)
            return

        volume.update_list_box_row()
        self.list_box.add(volume.list_box_row)
        self.volumes.append(volume)

        if len(self.volumes) == 1:
            self.hide_placeholder()

        self.list_box.show_all()
コード例 #3
0
 def on_volume_added(self, volume_monitor: Gio.VolumeMonitor,
                     gio_volume: Gio.Volume):
     logger.debug(
         "in on_volume_added. volume: %s",
         gio_volume.get_identifier(Gio.VOLUME_IDENTIFIER_KIND_UNIX_DEVICE))
     volume = Volume(self, gio_volume)
     if volume.is_tcrypt:
         self.add_volume(volume)
コード例 #4
0
    def _udisks_object_is_tcrypt(self, path: str) -> bool:
        if not path:
            return False

        udisks_object = self.udisks_client.get_object(path)
        if not udisks_object:
            return False

        return Volume(self, udisks_object=udisks_object).is_tcrypt
コード例 #5
0
    def get_all_volumes(self) -> List[Volume]:
        """Returns all connected volumes"""
        volumes = list()
        gio_volumes = self.gio_volume_monitor.get_volumes()

        for gio_volume in gio_volumes:
            device_file = gio_volume.get_identifier(
                Gio.VOLUME_IDENTIFIER_KIND_UNIX_DEVICE)
            if not device_file:
                continue

            logger.debug("volume: %s", device_file)

            try:
                volumes.append(Volume(self, gio_volume))
                logger.debug("is_file_container: %s",
                             volumes[-1].is_file_container)
                logger.debug("is_tcrypt: %s", volumes[-1].is_tcrypt)
                logger.debug("is_unlocked: %s", volumes[-1].is_unlocked)
            except UdisksObjectNotFoundError as e:
                logger.exception(e)

        return volumes
コード例 #6
0
 def on_volume_removed(self, volume_monitor: Gio.VolumeMonitor,
                       gio_volume: Gio.Volume):
     logger.debug(
         "in on_volume_removed. volume: %s",
         gio_volume.get_identifier(Gio.VOLUME_IDENTIFIER_KIND_UNIX_DEVICE))
     self.remove_volume(Volume(self, gio_volume, with_udisks=False))