[Python-modules-commits] [python-keyring] 01/01: New upstream version 10.5.0
Dmitry Shachnev
mitya57 at moszumanska.debian.org
Sun Dec 10 12:15:05 UTC 2017
This is an automated email from the git hooks/post-receive script.
mitya57 pushed a commit to branch upstream
in repository python-keyring.
commit 799ba8d9be4d3ae89f30c3779b274652123b180c
Author: Dmitry Shachnev <mitya57 at gmail.com>
Date: Sun Dec 10 15:13:54 2017 +0300
New upstream version 10.5.0
---
.travis-osx | 1 +
.travis.yml | 52 ++++++------
CHANGES.rst | 16 +++-
LICENSE | 7 ++
PKG-INFO | 18 +++--
README.rst | 12 +--
appveyor.yml | 6 +-
conftest.py | 2 +-
hook-keyring.backend.py | 4 +-
keyring.egg-info/PKG-INFO | 18 +++--
keyring.egg-info/SOURCES.txt | 1 +
keyring.egg-info/requires.txt | 1 +
keyring/__init__.py | 16 ++--
keyring/backend.py | 9 ++-
keyring/backends/OS_X.py | 6 +-
keyring/backends/SecretService.py | 15 ++--
keyring/backends/Windows.py | 6 +-
keyring/backends/_OS_X_API.py | 115 ++++++++++++++-------------
keyring/backends/kwallet.py | 16 ++--
keyring/cli.py | 18 +++--
keyring/core.py | 9 ++-
keyring/credentials.py | 5 +-
keyring/devpi_client.py | 3 +-
keyring/errors.py | 6 ++
keyring/http.py | 1 +
keyring/py27compat.py | 3 +
keyring/tests/backends/test_OS_X.py | 4 +-
keyring/tests/backends/test_SecretService.py | 6 +-
keyring/tests/backends/test_Windows.py | 2 +-
keyring/tests/backends/test_kwallet.py | 36 +++++----
keyring/tests/test_backend.py | 8 +-
keyring/tests/util.py | 11 ++-
keyring/util/__init__.py | 2 +
keyring/util/escape.py | 6 ++
keyring/util/platform_.py | 16 +++-
keyring/util/properties.py | 4 +
setup.cfg | 2 +-
setup.py | 14 +++-
tests/test_packaging.py | 1 +
tox.ini | 4 +-
40 files changed, 307 insertions(+), 175 deletions(-)
diff --git a/.travis-osx b/.travis-osx
index f22e09c..3178503 100644
--- a/.travis-osx
+++ b/.travis-osx
@@ -3,3 +3,4 @@ brew update
brew install python3
rm /usr/local/bin/python
ln -s python3 /usr/local/bin/python
+python -m pip install --upgrade tox
diff --git a/.travis.yml b/.travis.yml
index 44000b6..f0b5fb5 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,34 +1,36 @@
language: python
-python:
- - 2.7
- - 3.3
- - 3.4
- - 3.5
- - 3.6
-matrix:
+
+jobs:
+ fast_finish: true
include:
+ - python: 2.7
+ - python: 3.3
+ - python: &latest_py3 3.6
- os: osx
language: generic
+ - stage: deploy
+ if: tag IS present
+ python: *latest_py3
+ install: skip
+ script: skip
+ deploy:
+ provider: pypi
+ on:
+ tags: true
+ all_branches: true
+ user: jaraco
+ password:
+ secure: aDqlVdm6FZ8pqLkoDRR2LH3TEz7pBvKH2HhOlSy7OEmopN/36ncql/KvfE0ccpaOES9Xm31a51bUfNjcwb1HVKjfW544C+IoSHctkG1rI5bp3q4rW+4RbQcBZVHUUKR9yQf9ZyikEmoYXi3g+JKcOf9rj+v/32PAfUDzSpFbWik=
+ distributions: dists
+ skip_cleanup: true
+ skip_upload_docs: true
+
+cache: pip
before_install:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then source .travis-osx; fi
install:
-- python -m pip install tox "setuptools>=28.2"
-script:
-- tox -- -rs -v
-branches:
- except:
- - skeleton
-deploy:
- provider: pypi
- server: https://upload.pypi.org/legacy/
- on:
- tags: true
- all_branches: true
- python: 3.6
- user: jaraco
- password:
- secure: aDqlVdm6FZ8pqLkoDRR2LH3TEz7pBvKH2HhOlSy7OEmopN/36ncql/KvfE0ccpaOES9Xm31a51bUfNjcwb1HVKjfW544C+IoSHctkG1rI5bp3q4rW+4RbQcBZVHUUKR9yQf9ZyikEmoYXi3g+JKcOf9rj+v/32PAfUDzSpFbWik=
- distributions: dists
- skip_upload_docs: true
+- pip install tox
+
+script: tox
diff --git a/CHANGES.rst b/CHANGES.rst
index afb8a77..8125e29 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -1,3 +1,15 @@
+10.5.0
+------
+
+* #287: Added ``--list-backends`` option to
+ command-line interface.
+
+* Removed ``logger`` from ``keyring``. See #291 for related
+ request.
+
+* #292: Set the appid for SecretService & KWallet to
+ something meaningful.
+
10.4.0
------
@@ -487,7 +499,7 @@
* Removed support for Python 2.5.
* Removed names in ``keyring.backend`` moved in 1.1 and previously retained
- for compatibilty.
+ for compatibility.
2.1.1
-----
@@ -789,7 +801,7 @@ continue to operate normally. Any applications that customize the storage
location or make assumptions about the storage location will need to take
this change into consideration. Additionally, after upgrading to 0.8,
it is not possible to downgrade to 0.7 without manually moving
-configuration files. In 1.0, the backward compatibilty
+configuration files. In 1.0, the backward compatibility
will be removed.
0.7.1
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..5e795a6
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,7 @@
+Copyright Jason R. Coombs
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/PKG-INFO b/PKG-INFO
index 5b5be44..2e3143e 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,21 +1,22 @@
-Metadata-Version: 1.1
+Metadata-Version: 1.2
Name: keyring
-Version: 10.4.0
+Version: 10.5.0
Summary: Store and access your passwords safely.
Home-page: https://github.com/jaraco/keyring
Author: Jason R. Coombs
Author-email: jaraco at jaraco.com
License: UNKNOWN
+Description-Content-Type: UNKNOWN
Description: .. image:: https://img.shields.io/pypi/v/keyring.svg
:target: https://pypi.org/project/keyring
.. image:: https://img.shields.io/pypi/pyversions/keyring.svg
- .. image:: https://img.shields.io/pypi/dm/keyring.svg
-
.. image:: https://img.shields.io/travis/jaraco/keyring/master.svg
:target: http://travis-ci.org/jaraco/keyring
+ .. image:: https://readthedocs.org/projects/keyring/badge/?version=latest
+ :target: http://keyring.readthedocs.io/en/latest/?badge=latest
=======================================
Installing and Using Python Keyring Lib
@@ -27,7 +28,7 @@ Description: .. image:: https://img.shields.io/pypi/v/keyring.svg
What is Python keyring lib?
---------------------------
- The Python keyring lib provides a easy way to access the system keyring service
+ The Python keyring lib provides an easy way to access the system keyring service
from python. It can be used in any application that needs safe password storage.
The keyring library is licensed under both the `MIT license
@@ -42,8 +43,8 @@ Description: .. image:: https://img.shields.io/pypi/v/keyring.svg
`secretstorage <https://pypi.python.org/pypi/secretstorage>`_)
* `KWallet <https://en.wikipedia.org/wiki/KWallet>`_
(requires `dbus <https://pypi.python.org/pypi/dbus-python>`_)
- * `Windows Credential Vault
- <http://windows.microsoft.com/en-us/windows7/what-is-credential-manager>`_
+ * `Windows Credential Locker
+ <https://docs.microsoft.com/en-us/windows/uwp/security/credential-locker>`_
Other keyring implementations are provided in the `keyrings.alt package`_.
@@ -220,7 +221,7 @@ Description: .. image:: https://img.shields.io/pypi/v/keyring.svg
# invoke the keyring lib
try:
keyring.set_password("demo-service", "tarek", "passexample")
- print("password stored sucessfully")
+ print("password stored successfully")
except keyring.errors.PasswordSetError:
print("failed to store password")
print("password", keyring.get_password("demo-service", "tarek"))
@@ -362,3 +363,4 @@ Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
+Requires-Python: >=2.7
diff --git a/README.rst b/README.rst
index 5cbcb9a..2736ca9 100644
--- a/README.rst
+++ b/README.rst
@@ -3,11 +3,11 @@
.. image:: https://img.shields.io/pypi/pyversions/keyring.svg
-.. image:: https://img.shields.io/pypi/dm/keyring.svg
-
.. image:: https://img.shields.io/travis/jaraco/keyring/master.svg
:target: http://travis-ci.org/jaraco/keyring
+.. image:: https://readthedocs.org/projects/keyring/badge/?version=latest
+ :target: http://keyring.readthedocs.io/en/latest/?badge=latest
=======================================
Installing and Using Python Keyring Lib
@@ -19,7 +19,7 @@ Installing and Using Python Keyring Lib
What is Python keyring lib?
---------------------------
-The Python keyring lib provides a easy way to access the system keyring service
+The Python keyring lib provides an easy way to access the system keyring service
from python. It can be used in any application that needs safe password storage.
The keyring library is licensed under both the `MIT license
@@ -34,8 +34,8 @@ These recommended keyring backends are supported by the Python keyring lib:
`secretstorage <https://pypi.python.org/pypi/secretstorage>`_)
* `KWallet <https://en.wikipedia.org/wiki/KWallet>`_
(requires `dbus <https://pypi.python.org/pypi/dbus-python>`_)
-* `Windows Credential Vault
- <http://windows.microsoft.com/en-us/windows7/what-is-credential-manager>`_
+* `Windows Credential Locker
+ <https://docs.microsoft.com/en-us/windows/uwp/security/credential-locker>`_
Other keyring implementations are provided in the `keyrings.alt package`_.
@@ -212,7 +212,7 @@ Here's an example demonstrating how to invoke ``set_keyring``::
# invoke the keyring lib
try:
keyring.set_password("demo-service", "tarek", "passexample")
- print("password stored sucessfully")
+ print("password stored successfully")
except keyring.errors.PasswordSetError:
print("failed to store password")
print("password", keyring.get_password("demo-service", "tarek"))
diff --git a/appveyor.yml b/appveyor.yml
index d15473b..0a8ce5c 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -16,8 +16,6 @@ build: off
test_script:
- "python -m pip install tox"
- - "tox -- -rs -v"
+ - "tox"
-branches:
- except:
- - skeleton
+version: '{build}'
diff --git a/conftest.py b/conftest.py
index 5d0a1dc..7bd804c 100644
--- a/conftest.py
+++ b/conftest.py
@@ -5,6 +5,6 @@ collect_ignore = [
]
if platform.system() != 'Darwin':
- collect_ignore.append('keyring/backends/_OS_X_API.py')
+ collect_ignore.append('keyring/backends/_OS_X_API.py')
collect_ignore.append('keyring/devpi_client.py')
diff --git a/hook-keyring.backend.py b/hook-keyring.backend.py
index 5ba5949..27a4d24 100644
--- a/hook-keyring.backend.py
+++ b/hook-keyring.backend.py
@@ -11,6 +11,6 @@ hiddenimports = [
import pkg_resources
hiddenimports.extend(
- ep.module_name
- for ep in pkg_resources.iter_entry_points('keyring.backends')
+ ep.module_name
+ for ep in pkg_resources.iter_entry_points('keyring.backends')
)
diff --git a/keyring.egg-info/PKG-INFO b/keyring.egg-info/PKG-INFO
index 5b5be44..2e3143e 100644
--- a/keyring.egg-info/PKG-INFO
+++ b/keyring.egg-info/PKG-INFO
@@ -1,21 +1,22 @@
-Metadata-Version: 1.1
+Metadata-Version: 1.2
Name: keyring
-Version: 10.4.0
+Version: 10.5.0
Summary: Store and access your passwords safely.
Home-page: https://github.com/jaraco/keyring
Author: Jason R. Coombs
Author-email: jaraco at jaraco.com
License: UNKNOWN
+Description-Content-Type: UNKNOWN
Description: .. image:: https://img.shields.io/pypi/v/keyring.svg
:target: https://pypi.org/project/keyring
.. image:: https://img.shields.io/pypi/pyversions/keyring.svg
- .. image:: https://img.shields.io/pypi/dm/keyring.svg
-
.. image:: https://img.shields.io/travis/jaraco/keyring/master.svg
:target: http://travis-ci.org/jaraco/keyring
+ .. image:: https://readthedocs.org/projects/keyring/badge/?version=latest
+ :target: http://keyring.readthedocs.io/en/latest/?badge=latest
=======================================
Installing and Using Python Keyring Lib
@@ -27,7 +28,7 @@ Description: .. image:: https://img.shields.io/pypi/v/keyring.svg
What is Python keyring lib?
---------------------------
- The Python keyring lib provides a easy way to access the system keyring service
+ The Python keyring lib provides an easy way to access the system keyring service
from python. It can be used in any application that needs safe password storage.
The keyring library is licensed under both the `MIT license
@@ -42,8 +43,8 @@ Description: .. image:: https://img.shields.io/pypi/v/keyring.svg
`secretstorage <https://pypi.python.org/pypi/secretstorage>`_)
* `KWallet <https://en.wikipedia.org/wiki/KWallet>`_
(requires `dbus <https://pypi.python.org/pypi/dbus-python>`_)
- * `Windows Credential Vault
- <http://windows.microsoft.com/en-us/windows7/what-is-credential-manager>`_
+ * `Windows Credential Locker
+ <https://docs.microsoft.com/en-us/windows/uwp/security/credential-locker>`_
Other keyring implementations are provided in the `keyrings.alt package`_.
@@ -220,7 +221,7 @@ Description: .. image:: https://img.shields.io/pypi/v/keyring.svg
# invoke the keyring lib
try:
keyring.set_password("demo-service", "tarek", "passexample")
- print("password stored sucessfully")
+ print("password stored successfully")
except keyring.errors.PasswordSetError:
print("failed to store password")
print("password", keyring.get_password("demo-service", "tarek"))
@@ -362,3 +363,4 @@ Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
+Requires-Python: >=2.7
diff --git a/keyring.egg-info/SOURCES.txt b/keyring.egg-info/SOURCES.txt
index b73f966..71eb8d2 100644
--- a/keyring.egg-info/SOURCES.txt
+++ b/keyring.egg-info/SOURCES.txt
@@ -3,6 +3,7 @@
.travis-osx
.travis.yml
CHANGES.rst
+LICENSE
README.rst
appveyor.yml
conftest.py
diff --git a/keyring.egg-info/requires.txt b/keyring.egg-info/requires.txt
index 0187da2..08eb766 100644
--- a/keyring.egg-info/requires.txt
+++ b/keyring.egg-info/requires.txt
@@ -13,3 +13,4 @@ rst.linker>=1.9
[testing]
pytest>=2.8
pytest-sugar
+collective.checkdocs
diff --git a/keyring/__init__.py b/keyring/__init__.py
index 2289cee..0f63340 100644
--- a/keyring/__init__.py
+++ b/keyring/__init__.py
@@ -1,14 +1,16 @@
from __future__ import absolute_import
-import logging
-logger = logging.getLogger('keyring')
-
from .core import (set_keyring, get_keyring, set_password, get_password,
- delete_password)
+ delete_password)
from .getpassbackend import get_password as get_pass_get_password
try:
- import pkg_resources
- __version__ = pkg_resources.require('keyring')[0].version
+ import pkg_resources
+ __version__ = pkg_resources.get_distribution('keyring').version
except Exception:
- __version__ = 'unknown'
+ __version__ = 'unknown'
+
+__all__ = (
+ 'set_keyring', 'get_keyring', 'set_password', 'get_password',
+ 'delete_password', 'get_pass_get_password',
+)
diff --git a/keyring/backend.py b/keyring/backend.py
index 75e65da..b629bd3 100644
--- a/keyring/backend.py
+++ b/keyring/backend.py
@@ -98,6 +98,7 @@ class KeyringBackend(object):
"""
raise errors.PasswordDeleteError("reason")
+
class Crypter(object):
"""Base class providing encryption and decryption
"""
@@ -114,6 +115,7 @@ class Crypter(object):
"""
pass
+
class NullCrypter(Crypter):
"""A crypter that does nothing
"""
@@ -128,17 +130,19 @@ class NullCrypter(Crypter):
def _load_backend(name):
"Load a backend by name"
package = backends.__package__ or backends.__name__
- mod = importlib.import_module('.'+name, package)
+ mod = importlib.import_module('.' + name, package)
# invoke __name__ on each module to ensure it's loaded in demand-import
# environments
mod.__name__
+
def _load_backends():
"ensure that native keyring backends are loaded"
backends = 'kwallet', 'OS_X', 'SecretService', 'Windows'
list(map(_load_backend, backends))
_load_plugins()
+
def _load_plugins():
"""
Locate all setuptools entry points by the name 'keyring backends'
@@ -170,6 +174,7 @@ def _load_plugins():
except Exception:
log.exception("Error initializing plugin %s." % ep)
+
@util.once
def get_all_keyring():
"""
@@ -188,4 +193,4 @@ def get_all_keyring():
all_classes = KeyringBackend._classes
viable_classes = filter(is_class_viable, all_classes)
return list(util.suppress_exceptions(viable_classes,
- exceptions=TypeError))
+ exceptions=TypeError))
diff --git a/keyring/backends/OS_X.py b/keyring/backends/OS_X.py
index cd042a8..977ba38 100644
--- a/keyring/backends/OS_X.py
+++ b/keyring/backends/OS_X.py
@@ -32,7 +32,8 @@ class Keyring(KeyringBackend):
username = ''
try:
- api.set_generic_password(self.keychain, service, username, password)
+ api.set_generic_password(
+ self.keychain, service, username, password)
except api.Error:
raise PasswordSetError("Can't store password on keychain")
@@ -50,6 +51,7 @@ class Keyring(KeyringBackend):
username = ''
try:
- return api.delete_generic_password(self.keychain, service, username)
+ return api.delete_generic_password(
+ self.keychain, service, username)
except api.Error:
raise PasswordDeleteError("Can't delete password in keychain")
diff --git a/keyring/backends/SecretService.py b/keyring/backends/SecretService.py
index 1086d5c..e584be3 100644
--- a/keyring/backends/SecretService.py
+++ b/keyring/backends/SecretService.py
@@ -1,9 +1,12 @@
import logging
+import sys
+import os
+
from ..util import properties
from ..backend import KeyringBackend
from ..errors import (InitError, PasswordDeleteError,
- ExceptionRaisedContext)
+ ExceptionRaisedContext)
try:
import secretstorage
@@ -13,9 +16,10 @@ except ImportError:
log = logging.getLogger(__name__)
+
class Keyring(KeyringBackend):
"""Secret Service Keyring"""
- appid = "python-keyring"
+ appid = os.path.basename(sys.argv[0]) or 'Python keyring library'
@properties.ClassProperty
@classmethod
@@ -41,14 +45,15 @@ class Keyring(KeyringBackend):
bus = secretstorage.dbus_init()
try:
if hasattr(self, 'preferred_collection'):
- collection = secretstorage.Collection(bus, self.preferred_collection)
+ collection = secretstorage.Collection(
+ bus, self.preferred_collection)
else:
collection = secretstorage.get_default_collection(bus)
except exceptions.SecretStorageException as e:
raise InitError("Failed to create the collection: %s." % e)
if collection.is_locked():
collection.unlock()
- if collection.is_locked(): # User dismissed the prompt
+ if collection.is_locked(): # User dismissed the prompt
raise InitError("Failed to unlock the collection!")
return collection
@@ -72,7 +77,7 @@ class Keyring(KeyringBackend):
"application": self.appid,
"service": service,
"username": username
- }
+ }
label = "Password for '%s' on '%s'" % (username, service)
collection.create_item(label, attributes, password, replace=True)
diff --git a/keyring/backends/Windows.py b/keyring/backends/Windows.py
index 7f08e15..8c5dea3 100644
--- a/keyring/backends/Windows.py
+++ b/keyring/backends/Windows.py
@@ -21,6 +21,7 @@ except ImportError:
except ImportError:
pass
+
def has_pywin32():
"""
Does this environment have pywin32?
@@ -83,7 +84,7 @@ class WinVaultKeyring(KeyringBackend):
)
except pywintypes.error as e:
e = OldPywinError.wrap(e)
- if e.winerror == 1168 and e.funcname == 'CredRead': # not found
+ if e.winerror == 1168 and e.funcname == 'CredRead': # not found
return None
raise
return res
@@ -95,7 +96,7 @@ class WinVaultKeyring(KeyringBackend):
existing_username = existing_pw['UserName']
target = self._compound_name(existing_username, service)
self._set_password(target, existing_username,
- existing_pw['CredentialBlob'].decode('utf-16'))
+ existing_pw['CredentialBlob'].decode('utf-16'))
self._set_password(service, username, text_type(password))
def _set_password(self, target, username, password):
@@ -130,6 +131,7 @@ class OldPywinError(object):
A compatibility wrapper for old PyWin32 errors, such as reported in
https://bitbucket.org/kang/python-keyring-lib/issue/140/
"""
+
def __init__(self, orig):
self.orig = orig
diff --git a/keyring/backends/_OS_X_API.py b/keyring/backends/_OS_X_API.py
index 33e6ff2..b58104a 100644
--- a/keyring/backends/_OS_X_API.py
+++ b/keyring/backends/_OS_X_API.py
@@ -9,9 +9,11 @@ from keyring.py27compat import string_types, add_metaclass
sec_keychain_ref = sec_keychain_item_ref = c_void_p
OS_status = c_int32
+
class error:
item_not_found = -25300
+
fw = '/System/Library/Frameworks/{name}.framework/Versions/A/{name}'.format
_sec = ctypes.CDLL(fw(name='Security'))
_core = ctypes.CDLL(fw(name='CoreServices'))
@@ -25,7 +27,6 @@ SecKeychainOpen.argtypes = (
SecKeychainOpen.restype = OS_status
-
SecKeychainCopyDefault = _sec.SecKeychainCopyDefault
SecKeychainCopyDefault.argtypes = POINTER(sec_keychain_ref),
SecKeychainCopyDefault.restype = OS_status
@@ -62,6 +63,7 @@ def open(name):
finally:
_core.CFRelease(ref)
+
SecKeychainFindGenericPassword = _sec.SecKeychainFindGenericPassword
SecKeychainFindGenericPassword.argtypes = (
sec_keychain_ref,
@@ -75,35 +77,36 @@ SecKeychainFindGenericPassword.argtypes = (
)
SecKeychainFindGenericPassword.restype = OS_status
+
def find_generic_password(kc_name, service, username):
- username = username.encode('utf-8')
- service = service.encode('utf-8')
- with open(kc_name) as keychain:
- length = c_uint32()
- data = c_void_p()
- status = SecKeychainFindGenericPassword(
- keychain,
- len(service),
- service,
- len(username),
- username,
- length,
- data,
- None,
- )
-
- msg = "Can't fetch password from system"
- NotFound.raise_for_status(status, msg)
-
- password = ctypes.create_string_buffer(length.value)
- ctypes.memmove(password, data.value, length.value)
- SecKeychainItemFreeContent(None, data)
- return password.raw.decode('utf-8')
+ username = username.encode('utf-8')
+ service = service.encode('utf-8')
+ with open(kc_name) as keychain:
+ length = c_uint32()
+ data = c_void_p()
+ status = SecKeychainFindGenericPassword(
+ keychain,
+ len(service),
+ service,
+ len(username),
+ username,
+ length,
+ data,
+ None,
+ )
+
+ msg = "Can't fetch password from system"
+ NotFound.raise_for_status(status, msg)
+
+ password = ctypes.create_string_buffer(length.value)
+ ctypes.memmove(password, data.value, length.value)
+ SecKeychainItemFreeContent(None, data)
+ return password.raw.decode('utf-8')
SecKeychainFindInternetPassword = _sec.SecKeychainFindInternetPassword
SecKeychainFindInternetPassword.argtypes = (
- sec_keychain_ref, # keychainOrArray
+ sec_keychain_ref, # keychainOrArray
c_uint32, # serverNameLength
c_char_p, # serverName
c_uint32, # securityDomainLength
@@ -170,36 +173,36 @@ class SecAuthenticationType(object):
def find_internet_password(kc_name, service, username):
- username = username.encode('utf-8')
- domain = None
- service = service.encode('utf-8')
- path = None
- port = 0
-
- with open(kc_name) as keychain:
- length = c_uint32()
- data = c_void_p()
- status = SecKeychainFindInternetPassword(
- keychain,
- len(service), service,
- 0, domain,
- len(username), username,
- 0, path,
- port,
- SecProtocolType.kSecProtocolTypeHTTPS,
- SecAuthenticationType.kSecAuthenticationTypeAny,
- length,
- data,
- None,
- )
-
- msg = "Can't fetch password from system"
- NotFound.raise_for_status(status, msg)
-
- password = ctypes.create_string_buffer(length.value)
- ctypes.memmove(password, data.value, length.value)
- SecKeychainItemFreeContent(None, data)
- return password.raw.decode('utf-8')
+ username = username.encode('utf-8')
+ domain = None
+ service = service.encode('utf-8')
+ path = None
+ port = 0
+
+ with open(kc_name) as keychain:
+ length = c_uint32()
+ data = c_void_p()
+ status = SecKeychainFindInternetPassword(
+ keychain,
+ len(service), service,
+ 0, domain,
+ len(username), username,
+ 0, path,
+ port,
+ SecProtocolType.kSecProtocolTypeHTTPS,
+ SecAuthenticationType.kSecAuthenticationTypeAny,
+ length,
+ data,
+ None,
+ )
+
+ msg = "Can't fetch password from system"
+ NotFound.raise_for_status(status, msg)
+
+ password = ctypes.create_string_buffer(length.value)
+ ctypes.memmove(password, data.value, length.value)
+ SecKeychainItemFreeContent(None, data)
+ return password.raw.decode('utf-8')
SecKeychainAddGenericPassword = _sec.SecKeychainAddGenericPassword
@@ -244,7 +247,7 @@ def set_generic_password(name, service, username, password):
SecKeychainAddInternetPassword = _sec.SecKeychainAddInternetPassword
SecKeychainAddInternetPassword.argtypes = (
- sec_keychain_ref, # keychainOrArray
+ sec_keychain_ref, # keychainOrArray
c_uint32, # serverNameLength
c_char_p, # serverName
c_uint32, # securityDomainLength
diff --git a/keyring/backends/kwallet.py b/keyring/backends/kwallet.py
index 559f263..76ee92d 100644
--- a/keyring/backends/kwallet.py
+++ b/keyring/backends/kwallet.py
@@ -1,5 +1,8 @@
from __future__ import absolute_import
+import sys
+import os
+
from ..backend import KeyringBackend
from ..errors import PasswordDeleteError
from ..errors import PasswordSetError
@@ -17,7 +20,7 @@ class DBusKeyring(KeyringBackend):
KDE KWallet 5 via D-Bus
"""
- appid = 'Python program'
+ appid = os.path.basename(sys.argv[0]) or 'Python keyring library'
wallet = None
bus_name = 'org.kde.kwalletd5'
object_path = '/modules/kwalletd5'
@@ -48,7 +51,7 @@ class DBusKeyring(KeyringBackend):
entry_list = []
if self.iface.hasFolder(self.handle, old_folder, self.appid):
entry_list = self.iface.readPasswordList(
- self.handle, old_folder, '*@*', self.appid)
+ self.handle, old_folder, '*@*', self.appid)
for entry in entry_list.items():
key = entry[0]
@@ -56,12 +59,13 @@ class DBusKeyring(KeyringBackend):
username, service = key.rsplit('@', 1)
ret = self.iface.writePassword(
- self.handle, service, username, password, self.appid)
+ self.handle, service, username, password, self.appid)
if ret == 0:
- self.iface.removeEntry(self.handle, old_folder, key, self.appid)
+ self.iface.removeEntry(
+ self.handle, old_folder, key, self.appid)
entry_list = self.iface.readPasswordList(
- self.handle, old_folder, '*', self.appid)
+ self.handle, old_folder, '*', self.appid)
if not entry_list:
self.iface.removeFolder(self.handle, old_folder, self.appid)
@@ -74,7 +78,7 @@ class DBusKeyring(KeyringBackend):
remote_obj = bus.get_object(self.bus_name, self.object_path)
self.iface = dbus.Interface(remote_obj, 'org.kde.KWallet')
self.handle = self.iface.open(
- self.iface.networkWallet(), wId, self.appid)
+ self.iface.networkWallet(), wId, self.appid)
except dbus.DBusException:
self.handle = -1
if self.handle < 0:
diff --git a/keyring/cli.py b/keyring/cli.py
index 4fae821..aab596d 100755
--- a/keyring/cli.py
+++ b/keyring/cli.py
@@ -7,24 +7,33 @@ import getpass
from optparse import OptionParser
import sys
-from . import get_keyring, set_keyring, get_password, set_password, delete_password
from . import core
+from . import backend
+from . import get_keyring, set_keyring, get_password, set_password, delete_password
class CommandLineTool(object):
def __init__(self):
self.parser = OptionParser(
- usage="%prog [get|set|del] SERVICE USERNAME")
+ usage="%prog [get|set|del] SERVICE USERNAME")
self.parser.add_option("-p", "--keyring-path",
dest="keyring_path", default=None,
help="Path to the keyring backend")
self.parser.add_option("-b", "--keyring-backend",
dest="keyring_backend", default=None,
help="Name of the keyring backend")
+ self.parser.add_option("--list-backends",
+ action="store_true",
+ help="List keyring backends and exit")
def run(self, argv):
opts, args = self.parser.parse_args(argv)
+ if opts.list_backends:
+ for k in backend.get_all_keyring():
+ print(k)
+ return
+
try:
kind, service, username = args
except ValueError:
@@ -39,8 +48,7 @@ class CommandLineTool(object):
try:
if opts.keyring_path:
sys.path.insert(0, opts.keyring_path)
- backend = core.load_keyring(opts.keyring_backend)
- set_keyring(backend)
+ set_keyring(core.load_keyring(opts.keyring_backend))
except (Exception,):
# Tons of things can go wrong here:
# ImportError when using "fjkljfljkl"
@@ -66,7 +74,7 @@ class CommandLineTool(object):
elif kind == 'del':
password = self.input_password("Deleting password for '%s' in '%s': " %
- (username, service))
+ (username, service))
delete_password(service, username)
return 0
diff --git a/keyring/core.py b/keyring/core.py
index 1ccd883..228f375 100644
--- a/keyring/core.py
+++ b/keyring/core.py
@@ -10,7 +10,6 @@ import operator
from .py27compat import configparser, filter
from .py33compat import max
-from . import logger
from . import backend
from .util import platform_ as platform
from .backends import fail
@@ -20,6 +19,7 @@ log = logging.getLogger(__name__)
_keyring_backend = None
+
def set_keyring(keyring):
"""Set current keyring backend.
"""
@@ -53,7 +53,9 @@ def delete_password(service_name, username):
_keyring_backend.delete_password(service_name, username)
-recommended = lambda backend: backend.priority >= 1
+def recommended(backend): return backend.priority >= 1
+
+
by_priority = operator.attrgetter('priority')
@@ -130,12 +132,14 @@ def load_config():
raise configparser.NoOptionError('backend', 'default-keyring')
except (configparser.NoOptionError, ImportError):
+ logger = logging.getLogger('keyring')
logger.warning("Keyring config file contains incorrect values.\n" +
"Config file: %s" % keyring_cfg)
return
return load_keyring(keyring_name)
+
def _load_keyring_path(config):
"load the keyring-path option (if present)"
try:
@@ -144,5 +148,6 @@ def _load_keyring_path(config):
except (configparser.NoOptionError, configparser.NoSectionError):
pass
+
# init the _keyring_backend
init_backend()
diff --git a/keyring/credentials.py b/keyring/credentials.py
index 9947051..3609ae6 100644
--- a/keyring/credentials.py
+++ b/keyring/credentials.py
@@ -3,6 +3,7 @@ import abc
from .py27compat import add_metaclass
+
@add_metaclass(abc.ABCMeta)
class Credential(object):
"""Abstract class to manage credentials
@@ -16,6 +17,7 @@ class Credential(object):
def password(self):
return None
+
class SimpleCredential(Credential):
"""Simple credentials implementation
"""
@@ -32,6 +34,7 @@ class SimpleCredential(Credential):
def password(self):
return self._password
+
class EnvironCredential(Credential):
"""Source credentials from environment variables.
Actual sourcing is deferred until requested.
@@ -46,7 +49,7 @@ class EnvironCredential(Credential):
"""
value = os.environ.get(env_var)
if not value:
- raise ValueError('Missing environment variable:%s' %env_var)
+ raise ValueError('Missing environment variable:%s' % env_var)
return value
@property
diff --git a/keyring/devpi_client.py b/keyring/devpi_client.py
index 19e5f10..c9837fe 100644
--- a/keyring/devpi_client.py
+++ b/keyring/devpi_client.py
@@ -5,6 +5,7 @@ import keyring
hookimpl = HookimplMarker("devpiclient")
+
@hookimpl()
def devpiclient_get_password(url, username):
- return keyring.get_password(url, username)
... 526 lines suppressed ...
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-keyring.git
More information about the Python-modules-commits
mailing list