Example #1
0
    def __init__(self):
        self.loginDetails = False
        if gk.is_available() is True:
            if "Gusic" in gk.list_keyring_names_sync()[1]:
                self.keyring = gk.list_item_ids_sync("Gusic")[1]

                self.loginDetails = self._get_first_key("Gusic")

            else:
                gk.create_sync("Gusic", "Gusic")
 def __init__(self):
     self._protocol = "network"
     self._key = gk.ItemType.NETWORK_PASSWORD
     if not gk.is_available():
         raise KeyringException("The Gnome keyring is not available")
     logger.debug("GnomeKeyring is available")
     self.loaded = False
     self.lock = threading.RLock()
     
     if not self.loaded:
         (result, keyring_names) = gk.list_keyring_names_sync()
         if self._KEYRING_NAME not in keyring_names:
             logger.error("Error getting the gnome keyring. We'll try to create it: %s")
             logger.debug("Creating keyring " + self._KEYRING_NAME)
             gk.create_sync(self._KEYRING_NAME, None)
         self.loaded = True
Example #3
0
    def __init__(self):
        self._protocol = "network"
        self._key = gk.ItemType.NETWORK_PASSWORD
        if not gk.is_available():
            raise KeyringException("The Gnome keyring is not available")
        logger.debug("GnomeKeyring is available")
        self.loaded = False
        self.lock = threading.RLock()

        if not self.loaded:
            (result, keyring_names) = gk.list_keyring_names_sync()
            if self._KEYRING_NAME not in keyring_names:
                logger.error(
                    "Error getting the gnome keyring. We'll try to create it: %s"
                )
                logger.debug("Creating keyring " + self._KEYRING_NAME)
                gk.create_sync(self._KEYRING_NAME, None)
            self.loaded = True
Example #4
0
        # now query for it
        (result, info) = GnomeKeyring.item_get_info_sync(TEST_KEYRING, id)
        self.assertEqual(result, GnomeKeyring.Result.OK)
        self.assertEqual(info.get_display_name(), 'my_password')
        self.assertEqual(info.get_secret(), 'my_secret')

        # list_item_ids_sync()
        (result, items) = GnomeKeyring.list_item_ids_sync(TEST_KEYRING)
        self.assertEqual(result, GnomeKeyring.Result.OK)
        self.assertEqual(items, [id])

    def test_result_str(self):
        '''result_to_message()'''

        self.assertEqual(GnomeKeyring.result_to_message(GnomeKeyring.Result.OK),
                '')
        self.assertEqual(
                type(GnomeKeyring.result_to_message(GnomeKeyring.Result.NO_SUCH_KEYRING)),
                type(''))


#
# main
#

if not GnomeKeyring.is_available():
    print('GNOME keyring not available', file=sys.stderr)
    sys.exit(0)
unittest.main()
import os
import ConfigParser
from datetime import datetime

from utils import APP_NAME, LOCALE_DIR

import gettext
gettext.bindtextdomain(APP_NAME, LOCALE_DIR)
gettext.textdomain(APP_NAME)
_ = gettext.gettext


try:
    from gi.repository import GnomeKeyring
    USE_GNOME_KEYRING = GnomeKeyring.is_available()
    KEYRING_NAME = 'login'  # default keyring that gets unlocked normally when the user starts the session
    GUIFINETLOGINKEYNAME = 'guifinetlogin'
    print(_('Use GNOME Keyring: {}').format(USE_GNOME_KEYRING))
    GnomeKeyring.unlock_sync(KEYRING_NAME, None)
except ImportError:
    print(_('GNOME Keyring dependency not available'))
    print(_('Using plain text configuration files instead'))
    USE_GNOME_KEYRING = False


class GuifinetStudioConfig:
    CONFIG_DIR = os.path.expanduser('~/.config/guifinetstudio')
    CACHE_DIR = os.path.expanduser('~/.cache/guifinetstudio')
    CONFIG_FILENAME = os.path.join(CONFIG_DIR, 'config')
        # now query for it
        (result, info) = GnomeKeyring.item_get_info_sync(TEST_KEYRING, id)
        self.assertEqual(result, GnomeKeyring.Result.OK)
        self.assertEqual(info.get_display_name(), 'my_password')
        self.assertEqual(info.get_secret(), 'my_secret')

        # list_item_ids_sync()
        (result, items) = GnomeKeyring.list_item_ids_sync(TEST_KEYRING)
        self.assertEqual(result, GnomeKeyring.Result.OK)
        self.assertEqual(items, [id])

    def test_result_str(self):
        '''result_to_message()'''

        self.assertEqual(
            GnomeKeyring.result_to_message(GnomeKeyring.Result.OK), '')
        self.assertEqual(
            type(
                GnomeKeyring.result_to_message(
                    GnomeKeyring.Result.NO_SUCH_KEYRING)), type(''))


#
# main
#

if not GnomeKeyring.is_available():
    print('GNOME keyring not available', file=sys.stderr)
    sys.exit(0)
unittest.main()
Example #7
0
	def is_available(self):
		"""Return true if we are able to use Gnome keyring"""
		return keyring is not None and keyring.is_available()