How to use the udiskie.config.match_config function in udiskie

To help you get started, we’ve selected a few udiskie examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github coldfix / udiskie / test / test_match.py View on Github external
def mount_options(self, device):
        return match_config(self.filters, device, 'options', None)
github coldfix / udiskie / test / test_match.py View on Github external
def ignore_device(self, device):
        return match_config(self.filters, device, 'ignore', False)
github coldfix / udiskie / udiskie / mount.py View on Github external
def _ignore_device(self, device):
        return match_config(self._config, device, 'ignore', False)
github coldfix / udiskie / udiskie / mount.py View on Github external
def is_automount(self, device, default=True):
        if not self.is_handleable(device):
            return False
        return match_config(self._config, device, 'automount', default)
github coldfix / udiskie / udiskie / mount.py View on Github external
async def mount(self, device):
        """
        Mount the device if not already mounted.

        :param device: device object, block device path or mount path
        :returns: whether the device is mounted.
        """
        device = self._find_device(device)
        if not self.is_handleable(device) or not device.is_filesystem:
            self._log.warn(_('not mounting {0}: unhandled device', device))
            return False
        if device.is_mounted:
            self._log.info(_('not mounting {0}: already mounted', device))
            return True
        options = match_config(self._config, device, 'options', None)
        kwargs = dict(options=options)
        self._log.debug(_('mounting {0} with {1}', device, kwargs))
        self._check_device_before_mount(device)
        mount_path = await device.mount(**kwargs)
        self._log.info(_('mounted {0} on {1}', device, mount_path))
        return True
github coldfix / udiskie / udiskie / mount.py View on Github external
async def _unlock_from_keyfile(self, device):
        if not self.udisks.keyfile_support:
            return False
        filename = match_config(self._config, device, 'keyfile', None)
        if filename is None:
            self._log.debug(_('No matching keyfile rule for {}.', device))
            return False
        try:
            with open(filename, 'rb') as f:
                keyfile = f.read()
        except IOError:
            self._log.warn(_('keyfile for {0} not found: {1}', device, filename))
            return False
        self._log.debug(_('unlocking {0} using keyfile {1}', device, filename))
        try:
            await device.unlock_keyfile(keyfile)
        except Exception:
            self._log.debug(_('failed to unlock {0} using keyfile', device))
            self._log.debug(format_exc())
            return False