How to use the udiskie.cache.PasswordCache 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_cache.py View on Github external
def test_timeout(self):
        """The cached password expires after the specified timeout."""
        device = TestDev('ALPHA')
        password = '{<}hëllo ωορλδ!{>}'
        cache = PasswordCache(1)
        cache[device] = password
        self.assertEqual(cache[device], password)
        time.sleep(1.5)
        with self.assertRaises(KeyError):
            _ = cache[device]
github coldfix / udiskie / test / test_cache.py View on Github external
def test_update(self):
        device = TestDev('DELTA')
        password = '{<}hëllo ωορλδ!{>}'
        cache = PasswordCache(0)
        cache[device] = password
        self.assertEqual(cache[device], password)
        cache[device] = password * 2
        self.assertEqual(cache[device], password*2)
        del cache[device]
        with self.assertRaises(KeyError):
            _ = cache[device]
github coldfix / udiskie / test / test_cache.py View on Github external
def test_touch(self):
        """Key access refreshes the timeout."""
        device = TestDev('BETA')
        password = '{<}hëllo ωορλδ!{>}'
        cache = PasswordCache(3)
        cache[device] = password
        time.sleep(2)
        self.assertEqual(cache[device], password)
        time.sleep(2)
        self.assertEqual(cache[device], password)
        time.sleep(4)
        with self.assertRaises(KeyError):
            _ = cache[device]
github coldfix / udiskie / test / test_cache.py View on Github external
def test_revoke(self):
        """A key can be deleted manually."""
        device = TestDev('GAMMA')
        password = '{<}hëllo ωορλδ!{>}'
        cache = PasswordCache(0)
        cache[device] = password
        self.assertEqual(cache[device], password)
        del cache[device]
        with self.assertRaises(KeyError):
            _ = cache[device]
github coldfix / udiskie / udiskie / cli.py View on Github external
import udiskie.prompt

        config = self.config
        options = self.options

        # prepare mounter object
        prompt = udiskie.prompt.password(options['password_prompt'])
        browser = udiskie.prompt.browser(options['file_manager'])
        terminal = udiskie.prompt.browser(options['terminal'])
        cache = None

        try:
            import udiskie.cache
            timeout = int(options['password_cache']) * 60
            cache = udiskie.cache.PasswordCache(timeout)
        except ImportError:
            cache = None

        self.mounter = udiskie.mount.Mounter(
            config=config.device_config,
            prompt=prompt,
            browser=browser,
            terminal=terminal,
            cache=cache,
            cache_hint=options['password_cache'],
            udisks=self.udisks)

        # check component availability
        if options['notify'] and not has_Notify():
            libnotify_not_available = _(
                "Typelib for 'libnotify' is not available. Possible causes include:"