Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def wallet_list(self):
"""Return the list of available wallets, from Keyring
[('0', 'Manual', None, 'Disabled', True),
('1', 'UncryptedKeyring', , 'Recommended', False),
...]
"""
self._check_keyring()
import keyring
current = self.wallet_get()
out = [('0', 'Manual', None, 'Disabled', current == None)]
ref = {1: "Recommended", 0: "Supported", -1: "Not installed"}
for i, backend in enumerate(keyring.backend.get_all_keyring()):
out.append((str(i + 1),
backend.__class__.__name__,
backend,
ref[backend.supported()],
backend.__class__.__name__ == current,
))
return out
MaestralBackgroundTaskProgressDialog,
elide_string,
)
logger = logging.getLogger(__name__)
CONFIG_NAME = os.environ.get("MAESTRAL_CONFIG", "maestral")
# TODO: move this to sync.utils
if IS_MACOS_BUNDLE:
import keyring.backends.OS_X
keyring.set_keyring(keyring.backends.OS_X.Keyring())
else:
# get preferred keyring backends for platform, excluding the chainer backend
all_keyrings = keyring.backend.get_all_keyring()
preferred_kreyrings = [k for k in all_keyrings if not isinstance(k, keyring.backends.chainer.ChainerBackend)]
keyring.set_keyring(max(preferred_kreyrings, key=lambda x: x.priority))
# noinspection PyTypeChecker,PyArgumentList
class MaestralGuiApp(QtWidgets.QSystemTrayIcon):
"""A Qt GUI for the Maestral daemon."""
mdbx = None
_started = False
_context_menu_visible = False
PAUSE_TEXT = "Pause Syncing"
RESUME_TEXT = "Resume Syncing"
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Gajim. If not, see .
import logging
import keyring
from gajim.common import app
__all__ = ['get_password', 'save_password']
log = logging.getLogger('gajim.password')
backends = keyring.backend.get_all_keyring()
for backend in backends:
log.info('Found keyring backend: %s', backend)
keyring_backend = keyring.get_keyring()
log.info('Select %s backend', keyring_backend)
KEYRING_AVAILABLE = any(keyring.core.recommended(backend)
for backend in backends)
class SecretPasswordStorage:
"""
Store password using Keyring
"""
@staticmethod
def _some_keyring_available():
import keyring
backends = keyring.backend.get_all_keyring()
return any(keyring.core.recommended(backend) for backend in backends)
from maestral.config.main import CONF, SUBFOLDER
from maestral.config.base import get_conf_path
from maestral.sync.oauth_implicit import DropboxOAuth2FlowImplicit
from maestral.sync.errors import CONNECTION_ERRORS, DropboxAuthError
logger = logging.getLogger(__name__)
APP_KEY = "2jmbq42w7vof78h"
if IS_MACOS_BUNDLE:
import keyring.backends.OS_X
keyring.set_keyring(keyring.backends.OS_X.Keyring())
else:
# get preferred keyring backends for platform, excluding the chainer backend
all_keyrings = keyring.backend.get_all_keyring()
preferred_kreyrings = [k for k in all_keyrings if not isinstance(k, keyring.backends.chainer.ChainerBackend)]
keyring.set_keyring(max(preferred_kreyrings, key=lambda x: x.priority))
class OAuth2Session(object):
"""
OAuth2Session provides OAuth2 login and token store.
"""
TOKEN_FILE = osp.join(get_conf_path(SUBFOLDER), "o2_store.txt") # before v0.2.0
oAuth2FlowResult = None
Success = 0
InvalidToken = 1
ConnectionFailed = 2
def get_cookies(self):
salt = b'saltysalt'
length = 16
if sys.platform == 'darwin':
# running Chrome on OSX
key = None
# Look for key in all keychains, if nothing matches continue using
# None as key
for k in backend.get_all_keyring():
try:
my_pass = k.get_password('Chrome Safe Storage', 'Chrome')
if my_pass is not None:
my_pass = my_pass.encode('utf8')
iterations = 1003
key = PBKDF2(my_pass, salt, length, iterations)
break
except Exception as e:
pass
elif sys.platform.startswith('linux'):
# running Chrome on Linux
my_pass = 'peanuts'.encode('utf8')
iterations = 1
key = PBKDF2(my_pass, salt, length, iterations)