def get_mounts(self): # TODO we only support NTFS mounts = [] for volume_guid, list_of_mount_points in MountManager( ).get_mounts_of_all_volumes().items(): for mount_point in list_of_mount_points: mounts.append( WindowsMount(self.get_recommended_file_system(), volume_guid, mount_point)) return mounts
def _get_mount_point_for_labels(self, block_access_path): mount_points = [] for volume_guid, list_of_mount_points in MountManager( ).get_mounts_of_all_volumes().items(): if volume_guid != block_access_path: continue mount_points.extend(list_of_mount_points) if not mount_points: raise LabelNotSupported( "label can only be managed for mounted volumes") return mount_points[0]
def get_label(self, block_access_path): mount_point = self._get_mount_point_for_labels(block_access_path) return MountManager().get_volume_label(mount_point)
def set_label(self, block_access_path, label): mount_point = self._get_mount_point_for_labels(block_access_path) MountManager().set_volume_label(mount_point, label)
def unmount(self, block_access_path, mount_point): try: MountManager().remove_mount_point(block_access_path, mount_point) except: # diskmanagement module is a thin wrapper on top ctypes, does not differntiate error codes raise UnmountFailedDeviceIsBusy(block_access_path, mount_point)
def mount(self, block_access_path, mount_point, mount_options_dict={}): from .mount import WindowsMount # TODO we only support partitions assert 'Volume' in block_access_path MountManager().add_volume_mount_point(block_access_path, mount_point) return WindowsMount(self, block_access_path, mount_point)
def is_auto_mount(self): return MountManager().is_auto_mount()
def enable_auto_mount(self): MountManager().enable_auto_mount()
def disable_auto_mount(self): MountManager().disable_auto_mount()
def get_available_drive_letters(self): return MountManager().get_avaialable_drive_letters()
def __init__(self): super(WindowsMountManager, self).__init__() self.mount_manager = MountManager()