[Python-modules-commits] [python-secretstorage] 01/02: Import python-secretstorage_2.2.0.orig.tar.gz

Dmitry Shachnev mitya57 at moszumanska.debian.org
Sat Jun 18 15:03:06 UTC 2016


This is an automated email from the git hooks/post-receive script.

mitya57 pushed a commit to branch master
in repository python-secretstorage.

commit 36766cbacbccf0b5d70a7bd5592fc56207a8107a
Author: Dmitry Shachnev <mitya57 at gmail.com>
Date:   Sat Jun 18 18:01:59 2016 +0300

    Import python-secretstorage_2.2.0.orig.tar.gz
---
 .travis.yml                         | 18 ++++++++
 LICENSE                             |  2 +-
 PKG-INFO                            | 10 +++--
 README.rst                          |  8 +++-
 SecretStorage.egg-info/PKG-INFO     | 10 +++--
 SecretStorage.egg-info/SOURCES.txt  |  3 +-
 SecretStorage.egg-info/requires.txt |  1 +
 changelog                           | 14 +++++++
 docs/conf.py                        | 21 ++++++++--
 docs/index.rst                      |  6 +--
 secretstorage/__init__.py           | 83 ++-----------------------------------
 secretstorage/collection.py         | 14 +++----
 secretstorage/defines.py            |  2 +-
 secretstorage/item.py               | 22 ++++------
 secretstorage/util.py               | 16 ++++---
 setup.cfg                           |  2 +-
 setup.py                            |  4 +-
 tests/run_tests.py                  | 29 +++++++++++++
 tests/test_compat_functions.py      | 63 ----------------------------
 19 files changed, 140 insertions(+), 188 deletions(-)

diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..2c3f341
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,18 @@
+sudo: required
+dist: trusty
+language: python
+python:
+  - "2.7"
+  - "3.2"
+  - "3.3"
+  - "3.4"
+  - "3.5"
+before_install:
+  - sudo apt-get update
+  - sudo apt-get install -y libdbus-glib-1-dev
+install: pip install dbus-python pycrypto
+before_script:
+  - git clone git://git.gnome.org/libsecret.git
+script:
+  - dbus-launch --exit-with-session python tests/run_tests.py libsecret/libsecret/mock-service-normal.py
+  - dbus-launch --exit-with-session python tests/run_tests.py libsecret/libsecret/mock-service-only-plain.py
diff --git a/LICENSE b/LICENSE
index ae2da5b..2c19ef1 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,4 +1,4 @@
-Copyright 2012-2015 Dmitry Shachnev <mitya57 at gmail.com>
+Copyright 2012-2016 Dmitry Shachnev <mitya57 at gmail.com>
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
diff --git a/PKG-INFO b/PKG-INFO
index a802c47..8cc73f4 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,12 +1,16 @@
 Metadata-Version: 1.1
 Name: SecretStorage
-Version: 2.1.3
+Version: 2.2.0
 Summary: Python bindings to FreeDesktop.org Secret Service API
 Home-page: https://github.com/mitya57/secretstorage
 Author: Dmitry Shachnev
 Author-email: mitya57 at gmail.com
 License: BSD
 Description: 
+        .. image:: https://api.travis-ci.org/mitya57/secretstorage.svg
+           :target: https://travis-ci.org/mitya57/secretstorage
+           :alt: Travis CI status
+        
         Module description
         ==================
         
@@ -25,7 +29,7 @@ Description:
         
         The documentation can be found on `pythonhosted.org`_.
         
-        .. _`Secret Service`: http://standards.freedesktop.org/secret-service/
+        .. _`Secret Service`: https://specifications.freedesktop.org/secret-service/
         .. _`pythonhosted.org`: https://pythonhosted.org/SecretStorage/
         
         Building the module
@@ -48,7 +52,7 @@ Description:
         
            python3 setup.py build_sphinx
         
-        .. _`dbus-python`: http://www.freedesktop.org/wiki/Software/DBusBindings/#dbus-python
+        .. _`dbus-python`: https://www.freedesktop.org/wiki/Software/DBusBindings/#dbus-python
         .. _PyCrypto: https://www.dlitz.net/software/pycrypto/
         .. _`available on PyPI`: https://pypi.python.org/pypi/pycrypto
         .. _Sphinx: http://sphinx-doc.org/
diff --git a/README.rst b/README.rst
index eb13d24..41d265d 100644
--- a/README.rst
+++ b/README.rst
@@ -1,3 +1,7 @@
+.. image:: https://api.travis-ci.org/mitya57/secretstorage.svg
+   :target: https://travis-ci.org/mitya57/secretstorage
+   :alt: Travis CI status
+
 Module description
 ==================
 
@@ -16,7 +20,7 @@ locking and unlocking collections (asynchronous unlocking is also supported).
 
 The documentation can be found on `pythonhosted.org`_.
 
-.. _`Secret Service`: http://standards.freedesktop.org/secret-service/
+.. _`Secret Service`: https://specifications.freedesktop.org/secret-service/
 .. _`pythonhosted.org`: https://pythonhosted.org/SecretStorage/
 
 Building the module
@@ -39,7 +43,7 @@ If you have Sphinx_ installed, you can also build the documentation::
 
    python3 setup.py build_sphinx
 
-.. _`dbus-python`: http://www.freedesktop.org/wiki/Software/DBusBindings/#dbus-python
+.. _`dbus-python`: https://www.freedesktop.org/wiki/Software/DBusBindings/#dbus-python
 .. _PyCrypto: https://www.dlitz.net/software/pycrypto/
 .. _`available on PyPI`: https://pypi.python.org/pypi/pycrypto
 .. _Sphinx: http://sphinx-doc.org/
diff --git a/SecretStorage.egg-info/PKG-INFO b/SecretStorage.egg-info/PKG-INFO
index a802c47..8cc73f4 100644
--- a/SecretStorage.egg-info/PKG-INFO
+++ b/SecretStorage.egg-info/PKG-INFO
@@ -1,12 +1,16 @@
 Metadata-Version: 1.1
 Name: SecretStorage
-Version: 2.1.3
+Version: 2.2.0
 Summary: Python bindings to FreeDesktop.org Secret Service API
 Home-page: https://github.com/mitya57/secretstorage
 Author: Dmitry Shachnev
 Author-email: mitya57 at gmail.com
 License: BSD
 Description: 
+        .. image:: https://api.travis-ci.org/mitya57/secretstorage.svg
+           :target: https://travis-ci.org/mitya57/secretstorage
+           :alt: Travis CI status
+        
         Module description
         ==================
         
@@ -25,7 +29,7 @@ Description:
         
         The documentation can be found on `pythonhosted.org`_.
         
-        .. _`Secret Service`: http://standards.freedesktop.org/secret-service/
+        .. _`Secret Service`: https://specifications.freedesktop.org/secret-service/
         .. _`pythonhosted.org`: https://pythonhosted.org/SecretStorage/
         
         Building the module
@@ -48,7 +52,7 @@ Description:
         
            python3 setup.py build_sphinx
         
-        .. _`dbus-python`: http://www.freedesktop.org/wiki/Software/DBusBindings/#dbus-python
+        .. _`dbus-python`: https://www.freedesktop.org/wiki/Software/DBusBindings/#dbus-python
         .. _PyCrypto: https://www.dlitz.net/software/pycrypto/
         .. _`available on PyPI`: https://pypi.python.org/pypi/pycrypto
         .. _Sphinx: http://sphinx-doc.org/
diff --git a/SecretStorage.egg-info/SOURCES.txt b/SecretStorage.egg-info/SOURCES.txt
index 8fc523e..88776c5 100644
--- a/SecretStorage.egg-info/SOURCES.txt
+++ b/SecretStorage.egg-info/SOURCES.txt
@@ -1,4 +1,5 @@
 .gitignore
+.travis.yml
 LICENSE
 MANIFEST.in
 README.rst
@@ -23,8 +24,8 @@ secretstorage/exceptions.py
 secretstorage/item.py
 secretstorage/util.py
 tests/cleanup_test_items.py
+tests/run_tests.py
 tests/test_collection.py
-tests/test_compat_functions.py
 tests/test_dhcrypto.py
 tests/test_exceptions.py
 tests/test_item.py
\ No newline at end of file
diff --git a/SecretStorage.egg-info/requires.txt b/SecretStorage.egg-info/requires.txt
index 904545b..f239437 100644
--- a/SecretStorage.egg-info/requires.txt
+++ b/SecretStorage.egg-info/requires.txt
@@ -1 +1,2 @@
+dbus-python
 pycrypto
diff --git a/changelog b/changelog
index 953d7f0..1b9c357 100644
--- a/changelog
+++ b/changelog
@@ -1,3 +1,17 @@
+SecretStorage 2.2.0, 2016-06-18
+===============================
+
+* Deprecated compatibility functions are dropped.
+* Installation from PyPI now pulls in dbus-python.
+* Travis CI tests added.
+* Other minor fixes, simplifications and improvements.
+
+SecretStorage 2.1.4, 2016-01-10
+===============================
+
+* Catch AccessDenied errors in dbus_init() function.
+* Documentation improvements.
+
 SecretStorage 2.1.3, 2015-12-20
 ===============================
 
diff --git a/docs/conf.py b/docs/conf.py
index c05b2c1..c5a7a08 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -24,16 +24,16 @@ master_doc = 'index'
 
 # General information about the project.
 project = 'SecretStorage'
-copyright = '2015, Dmitry Shachnev'
+copyright = '2016, Dmitry Shachnev'
 
 # The version info for the project you're documenting, acts as replacement for
 # |version| and |release|, also used in various other places throughout the
 # built documents.
 #
 # The short X.Y version.
-version = '2.1'
+version = '2.2'
 # The full version, including alpha/beta/rc tags.
-release = '2.1.3'
+release = '2.2.0'
 
 # The name of the Pygments (syntax highlighting) style to use.
 pygments_style = 'sphinx'
@@ -44,6 +44,21 @@ pygments_style = 'sphinx'
 # a list of builtin themes.
 html_theme = 'alabaster'
 
+# Theme options are theme-specific and customize the look and feel of a theme
+# further.  For a list of options available for each theme, see the
+# documentation.
+html_theme_options = {
+    'description': 'Python bindings to the FreeDesktop.org Secret Service API',
+    'description_font_style': 'italic',
+    'github_button': False,
+    'sidebar_width': '260px',
+}
+
+# Custom sidebar templates, maps document names to template names.
+html_sidebars = {
+    '**': ['about.html', 'navigation.html', 'sourcelink.html', 'searchbox.html']
+}
+
 # -- Options for LaTeX output --------------------------------------------------
 
 # Grouping the document tree into LaTeX files. List of tuples
diff --git a/docs/index.rst b/docs/index.rst
index d2e0206..481f0bd 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -13,8 +13,8 @@ It allows one to create new secret items, delete and search for
 passwords matching given attributes. It also supports graphical prompts
 when unlocking is needed.
 
-.. _`D-Bus`: http://www.freedesktop.org/wiki/Software/dbus
-.. _`Secret Service`: http://standards.freedesktop.org/secret-service/
+.. _`D-Bus`: https://www.freedesktop.org/wiki/Software/dbus
+.. _`Secret Service`: https://specifications.freedesktop.org/secret-service/
 .. _`GNOME Keyring`: https://wiki.gnome.org/Projects/GnomeKeyring
 .. _KSecretsService: https://techbase.kde.org/Projects/Utils/ksecretsservice
 
@@ -29,7 +29,7 @@ Initializing D-Bus
    If you don't know how D-Bus works, please read `Introduction to D-Bus`_
    firstly.
 
-   .. _`Introduction to D-Bus`: http://www.freedesktop.org/wiki/IntroductionToDBus
+   .. _`Introduction to D-Bus`: https://www.freedesktop.org/wiki/IntroductionToDBus
 
 Before using SecretStorage, you need to initialize D-Bus. This can be done
 using this function:
diff --git a/secretstorage/__init__.py b/secretstorage/__init__.py
index 6a4810c..cddfbf6 100644
--- a/secretstorage/__init__.py
+++ b/secretstorage/__init__.py
@@ -16,15 +16,12 @@ from secretstorage.collection import Collection, create_collection, \
  get_collection_by_alias, search_items
 from secretstorage.item import Item
 from secretstorage.defines import DBUS_NOT_SUPPORTED, DBUS_EXEC_FAILED, \
- DBUS_NO_REPLY
+ DBUS_NO_REPLY, DBUS_ACCESS_DENIED
 from secretstorage.exceptions import SecretStorageException, \
  SecretServiceNotAvailableException, LockedException, \
  ItemNotFoundException
-from os.path import join
-from functools import wraps
-from warnings import warn
 
-__version_tuple__ = (2, 1, 3)
+__version_tuple__ = (2, 2, 0)
 __version__ = '.'.join(map(str, __version_tuple__))
 
 def dbus_init(main_loop=True, use_qt_loop=False):
@@ -33,7 +30,7 @@ def dbus_init(main_loop=True, use_qt_loop=False):
 	(PyQt5 main loop if `use_qt_loop` is :const:`True`, otherwise GLib
 	main loop).
 
-	.. _SessionBus: http://www.freedesktop.org/wiki/IntroductionToDBus/#buses
+	.. _SessionBus: https://www.freedesktop.org/wiki/IntroductionToDBus/#buses
 
 	.. note::
 	   Qt uses GLib main loops on UNIX-like systems by default, so one
@@ -50,79 +47,7 @@ def dbus_init(main_loop=True, use_qt_loop=False):
 		return dbus.SessionBus()
 	except dbus.exceptions.DBusException as e:
 		if e.get_dbus_name() in (DBUS_NOT_SUPPORTED,
-		DBUS_EXEC_FAILED, DBUS_NO_REPLY):
+		DBUS_EXEC_FAILED, DBUS_NO_REPLY, DBUS_ACCESS_DENIED):
 			raise SecretServiceNotAvailableException(
 				e.get_dbus_message())
 		raise
-
-# The functions below are provided for compatibility with old
-# SecretStorage versions (<= 0.2).
-
-def _deprecated(function_in):
-	@wraps(function_in)
-	def function_out(*args, **kwargs):
-		warn('Function %s is deprecated. Please use the documented API'
-		     ' instead.' % function_in.__name__, DeprecationWarning,
-		     stacklevel=2)
-		return function_in(*args, **kwargs)
-	return function_out
-
- at _deprecated
-def get_items(search_attributes, unlock_all=True):
-	"""Returns tuples for all items in the default collection matching
-	`search_attributes`."""
-	bus = dbus_init()
-	collection = get_any_collection(bus)
-	if unlock_all and collection.is_locked():
-		collection.unlock()
-	search_results = collection.search_items(search_attributes)
-	return [item.to_tuple() for item in search_results]
-
- at _deprecated
-def get_items_ids(search_attributes):
-	"""Returns item id for all items in the default collection matching
-	`search_attributes`."""
-	bus = dbus_init()
-	collection = get_any_collection(bus)
-	search_results = collection.search_items(search_attributes)
-	return [item._item_id() for item in search_results]
-
- at _deprecated
-def get_item_attributes(item_id):
-	"""Returns item attributes for item with given id."""
-	bus = dbus_init()
-	collection = get_any_collection(bus)
-	item = Item(bus, join(collection.collection_path, str(item_id)))
-	return item.get_attributes()
-
- at _deprecated
-def get_item_object(item_id, unlock=True):
-	"""Returns the item with given id and unlocks it if `unlock` is
-	`True`."""
-	bus = dbus_init()
-	collection = get_any_collection(bus)
-	item = Item(bus, join(collection.collection_path, str(item_id)))
-	if unlock and collection.is_locked():
-		collection.unlock()
-	return item
-
- at _deprecated
-def get_item(item_id, unlock=True):
-	"""Returns tuple representing the item with given id."""
-	return get_item_object(item_id, unlock).to_tuple()
-
- at _deprecated
-def delete_item(item_id, unlock=True):
-	"""Deletes the item with given id."""
-	return get_item_object(item_id, unlock).delete()
-
- at _deprecated
-def create_item(label, attributes, secret, unlock=True):
-	"""Creates an item with given `label`, `attributes` and `secret` in
-	the default collection. Returns id of the created item."""
-	bus = dbus_init()
-	collection = get_any_collection(bus)
-	if unlock and collection.is_locked():
-		collection.unlock()
-	item = collection.create_item(label, attributes, secret)
-	return item._item_id()
diff --git a/secretstorage/collection.py b/secretstorage/collection.py
index d48823e..02d5836 100644
--- a/secretstorage/collection.py
+++ b/secretstorage/collection.py
@@ -16,7 +16,7 @@ asynchronous). Creating new items and editing existing ones is possible
 only in unlocked collection."""
 
 import dbus
-from secretstorage.defines import SS_PREFIX, SS_PATH, SECRETS
+from secretstorage.defines import SS_PREFIX, SS_PATH
 from secretstorage.exceptions import LockedException, ItemNotFoundException
 from secretstorage.item import Item
 from secretstorage.util import bus_get_object, InterfaceWrapper, \
@@ -31,7 +31,7 @@ class Collection(object):
 	"""Represents a collection."""
 
 	def __init__(self, bus, collection_path=DEFAULT_COLLECTION, session=None):
-		collection_obj = bus_get_object(bus, SECRETS, collection_path)
+		collection_obj = bus_get_object(bus, collection_path)
 		self.bus = bus
 		self.session = session
 		self.collection_path = collection_path
@@ -64,7 +64,7 @@ class Collection(object):
 
 	def lock(self):
 		"""Locks the collection."""
-		service_obj = bus_get_object(self.bus, SECRETS, SS_PATH)
+		service_obj = bus_get_object(self.bus, SS_PATH)
 		service_iface = InterfaceWrapper(service_obj, SERVICE_IFACE)
 		service_iface.Lock([self.collection_path], signature='ao')
 
@@ -128,7 +128,7 @@ def create_collection(bus, label, alias='', session=None):
 	if not session:
 		session = open_session(bus)
 	properties = {SS_PREFIX+'Collection.Label': label}
-	service_obj = bus_get_object(bus, SECRETS, SS_PATH)
+	service_obj = bus_get_object(bus, SS_PATH)
 	service_iface = dbus.Interface(service_obj, SERVICE_IFACE)
 	collection_path, prompt = service_iface.CreateCollection(properties,
 		alias, signature='a{sv}s')
@@ -141,7 +141,7 @@ def create_collection(bus, label, alias='', session=None):
 
 def get_all_collections(bus):
 	"""Returns a generator of all available collections."""
-	service_obj = bus_get_object(bus, SECRETS, SS_PATH)
+	service_obj = bus_get_object(bus, SS_PATH)
 	service_props_iface = dbus.Interface(service_obj,
 		dbus.PROPERTIES_IFACE)
 	for collection_path in service_props_iface.Get(SERVICE_IFACE,
@@ -183,7 +183,7 @@ def get_collection_by_alias(bus, alias):
 	"""Returns the collection with the given `alias`. If there is no
 	such collection, raises
 	:exc:`~secretstorage.exceptions.ItemNotFoundException`."""
-	service_obj = bus_get_object(bus, SECRETS, SS_PATH)
+	service_obj = bus_get_object(bus, SS_PATH)
 	service_iface = dbus.Interface(service_obj, SERVICE_IFACE)
 	collection_path = service_iface.ReadAlias(alias, signature='s')
 	if len(collection_path) <= 1:
@@ -193,7 +193,7 @@ def get_collection_by_alias(bus, alias):
 def search_items(bus, attributes):
 	"""Returns a generator of items in all collections with the given
 	attributes. `attributes` should be a dictionary."""
-	service_obj = bus_get_object(bus, SECRETS, SS_PATH)
+	service_obj = bus_get_object(bus, SS_PATH)
 	service_iface = dbus.Interface(service_obj, SERVICE_IFACE)
 	locked, unlocked = service_iface.SearchItems(attributes,
 		signature='a{ss}')
diff --git a/secretstorage/defines.py b/secretstorage/defines.py
index 95a126c..e7fa96a 100644
--- a/secretstorage/defines.py
+++ b/secretstorage/defines.py
@@ -5,11 +5,11 @@
 
 # This file contains some common defines.
 
-SECRETS = 'org.freedesktop.secrets'
 SS_PREFIX = 'org.freedesktop.Secret.'
 SS_PATH = '/org/freedesktop/secrets'
 
 DBUS_UNKNOWN_METHOD  = 'org.freedesktop.DBus.Error.UnknownMethod'
+DBUS_ACCESS_DENIED   = 'org.freedesktop.DBus.Error.AccessDenied'
 DBUS_SERVICE_UNKNOWN = 'org.freedesktop.DBus.Error.ServiceUnknown'
 DBUS_EXEC_FAILED     = 'org.freedesktop.DBus.Error.Spawn.ExecFailed'
 DBUS_NO_REPLY        = 'org.freedesktop.DBus.Error.NoReply'
diff --git a/secretstorage/item.py b/secretstorage/item.py
index a1d8257..506f46c 100644
--- a/secretstorage/item.py
+++ b/secretstorage/item.py
@@ -10,24 +10,20 @@ the item is unlocked. The collection can be unlocked using collection's
 :meth:`~secretstorage.collection.Collection.unlock` method."""
 
 import dbus
-from secretstorage.defines import SECRETS, SS_PREFIX
+from secretstorage.defines import SS_PREFIX
 from secretstorage.exceptions import LockedException
 from secretstorage.util import InterfaceWrapper, bus_get_object, \
  open_session, format_secret, to_unicode, unlock_objects
 from Crypto.Cipher.AES import AESCipher, MODE_CBC
 
 ITEM_IFACE = SS_PREFIX + 'Item'
-DEFAULT_COLLECTION = '/org/freedesktop/secrets/aliases/default'
 
 class Item(object):
 	"""Represents a secret item."""
 
 	def __init__(self, bus, item_path, session=None):
-		if isinstance(item_path, int):
-			# An item id was specified instead of the path
-			item_path = '%s/%d' % (DEFAULT_COLLECTION, item_path)
 		self.item_path = item_path
-		item_obj = bus_get_object(bus, SECRETS, item_path)
+		item_obj = bus_get_object(bus, item_path)
 		self.session = session
 		self.bus = bus
 		self.item_iface = InterfaceWrapper(item_obj, ITEM_IFACE)
@@ -36,11 +32,7 @@ class Item(object):
 		self.item_props_iface.Get(ITEM_IFACE, 'Label', signature='ss')
 
 	def __eq__(self, other):
-		return (self._item_id() == other._item_id()) \
-		and (self.get_attributes() == other.get_attributes())
-
-	def _item_id(self):
-		return int(self.item_path.rsplit('/', 1)[1])
+		return self.item_path == other.item_path
 
 	def is_locked(self):
 		"""Returns :const:`True` if item is locked, otherwise
@@ -61,7 +53,9 @@ class Item(object):
 		If `callback` is specified, calls it when unlocking is complete
 		(see :func:`~secretstorage.util.exec_prompt` description for
 		details). Otherwise, uses the loop from GLib API and returns a
-		boolean representing whether the operation was dismissed."""
+		boolean representing whether the operation was dismissed.
+
+		.. versionadded:: 2.1.2"""
 		return unlock_objects(self.bus, [self.item_path], callback)
 
 	def get_attributes(self):
@@ -129,7 +123,9 @@ class Item(object):
 
 	def get_created(self):
 		"""Returns UNIX timestamp (integer) representing the time
-		when the item was created."""
+		when the item was created.
+
+		.. versionadded:: 1.1"""
 		return int(self.item_props_iface.Get(ITEM_IFACE, 'Created',
 			signature='ss'))
 
diff --git a/secretstorage/util.py b/secretstorage/util.py
index 7308a6b..f39d890 100644
--- a/secretstorage/util.py
+++ b/secretstorage/util.py
@@ -9,7 +9,7 @@ normally be used by external applications."""
 import dbus
 from secretstorage.defines import DBUS_UNKNOWN_METHOD, DBUS_NO_SUCH_OBJECT, \
  DBUS_SERVICE_UNKNOWN, DBUS_NO_REPLY, DBUS_NOT_SUPPORTED, DBUS_EXEC_FAILED, \
- SECRETS, SS_PATH, SS_PREFIX, ALGORITHM_DH, ALGORITHM_PLAIN
+ SS_PATH, SS_PREFIX, ALGORITHM_DH, ALGORITHM_PLAIN
 from secretstorage.dhcrypto import Session
 from secretstorage.exceptions import ItemNotFoundException, \
  SecretServiceNotAvailableException
@@ -17,6 +17,7 @@ from Crypto.Random import get_random_bytes
 from Crypto.Cipher.AES import AESCipher, MODE_CBC, block_size
 from secretstorage.dhcrypto import long_to_bytes, bytes_to_long
 
+BUS_NAME = 'org.freedesktop.secrets'
 SERVICE_IFACE = SS_PREFIX + 'Service'
 
 class InterfaceWrapper(dbus.Interface):
@@ -44,10 +45,11 @@ class InterfaceWrapper(dbus.Interface):
 			result = self.catch_errors(result)
 		return result
 
-def bus_get_object(bus, name, object_path):
+def bus_get_object(bus, object_path, service_name=None):
 	"""A wrapper around :meth:`SessionBus.get_object` that raises
 	:exc:`~secretstorage.exceptions.SecretServiceNotAvailableException`
 	when appropriate."""
+	name = service_name or BUS_NAME
 	try:
 		return bus.get_object(name, object_path, introspect=False)
 	except dbus.exceptions.DBusException as e:
@@ -58,7 +60,7 @@ def bus_get_object(bus, name, object_path):
 
 def open_session(bus):
 	"""Returns a new Secret Service session."""
-	service_obj = bus_get_object(bus, SECRETS, SS_PATH)
+	service_obj = bus_get_object(bus, SS_PATH)
 	service_iface = dbus.Interface(service_obj, SS_PREFIX+'Service')
 	session = Session()
 	try:
@@ -106,7 +108,7 @@ def exec_prompt(bus, prompt, callback):
 	function with two arguments: a boolean representing whether the
 	operation was dismissed and a list of unlocked item paths. A main
 	loop should be running and registered for this function to work."""
-	prompt_obj = bus_get_object(bus, SECRETS, prompt)
+	prompt_obj = bus_get_object(bus, prompt)
 	prompt_iface = dbus.Interface(prompt_obj, SS_PREFIX+'Prompt')
 	prompt_iface.Prompt('', signature='s')
 	def new_callback(dismissed, unlocked):
@@ -148,8 +150,10 @@ def unlock_objects(bus, paths, callback=None):
 	is specified, calls it when unlocking is complete (see
 	:func:`exec_prompt` description for details).
 	Otherwise, uses the loop from GLib API and returns a boolean
-	representing whether the operation was dismissed."""
-	service_obj = bus_get_object(bus, SECRETS, SS_PATH)
+	representing whether the operation was dismissed.
+
+	.. versionadded:: 2.1.2"""
+	service_obj = bus_get_object(bus, SS_PATH)
 	service_iface = InterfaceWrapper(service_obj, SERVICE_IFACE)
 	unlocked_paths, prompt = service_iface.Unlock(paths, signature='ao')
 	unlocked_paths = list(unlocked_paths)  # Convert from dbus.Array
diff --git a/setup.cfg b/setup.cfg
index 6bc2ff3..861a9f5 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,5 +1,5 @@
 [egg_info]
-tag_date = 0
 tag_build = 
+tag_date = 0
 tag_svn_revision = 0
 
diff --git a/setup.py b/setup.py
index a8ffe0a..0759880 100755
--- a/setup.py
+++ b/setup.py
@@ -6,7 +6,7 @@ try:
 except ImportError:
 	from distutils.core import setup
 
-version = '2.1.3'
+version = '2.2.0'
 
 readme_file = open(os.path.join(os.path.dirname(__file__), 'README.rst'))
 long_description = '\n' + readme_file.read()
@@ -40,6 +40,6 @@ setup(name='SecretStorage',
 	platforms='Linux',
 	license='BSD',
 	classifiers=classifiers,
-	install_requires=['pycrypto'],
+	install_requires=['dbus-python', 'pycrypto'],
 	requires=['dbus', 'Crypto']
 )
diff --git a/tests/run_tests.py b/tests/run_tests.py
new file mode 100644
index 0000000..51abb18
--- /dev/null
+++ b/tests/run_tests.py
@@ -0,0 +1,29 @@
+#!/usr/bin/env python
+
+import os.path
+import sys
+import subprocess
+import unittest
+
+tests_dir = os.path.dirname(__file__)
+sys.path.insert(0, os.path.dirname(tests_dir))
+
+import secretstorage
+
+if __name__ == '__main__':
+	print('Running with Python %d.%d.%d (SecretStorage from %s)' %
+	      (sys.version_info[:3] + (os.path.dirname(secretstorage.__file__),)))
+	mock = None
+	if len(sys.argv) > 1 and os.path.isfile(sys.argv[1]):
+		mock = subprocess.Popen(('/usr/bin/python3', sys.argv[1],),
+		                        stdout=subprocess.PIPE,
+		                        universal_newlines=True)
+		bus_name = mock.stdout.readline().rstrip()
+		secretstorage.util.BUS_NAME = bus_name
+		print('Bus name set to %r' % secretstorage.util.BUS_NAME)
+	loader = unittest.TestLoader()
+	runner = unittest.TextTestRunner(verbosity=2)
+	result = runner.run(loader.discover(tests_dir))
+	if mock is not None:
+		mock.terminate()
+	sys.exit(not result.wasSuccessful())
diff --git a/tests/test_compat_functions.py b/tests/test_compat_functions.py
deleted file mode 100644
index e59ec2b..0000000
--- a/tests/test_compat_functions.py
+++ /dev/null
@@ -1,63 +0,0 @@
-# Tests for SecretStorage
-# Author: Dmitry Shachnev, 2013
-# License: BSD
-
-# This file tests the compatibility functions in __init__.py.
-
-import secretstorage
-import random
-import unittest
-
-rand = str(random.randint(0, 1000))
-
-ATTRIBUTES = {'application': 'secretstorage-test', 'attribute': rand}
-PASSWORD = b'pa$$word'
-
-def catch_deprecation_warnings(testcase, function_in):
-	if not hasattr(testcase, 'assertWarns'):
-		return function_in
-	def function_out(*args, **kwargs):
-		with testcase.assertWarns(DeprecationWarning):
-			return function_in(*args, **kwargs)
-	return function_out
-
-class CompatFunctionsTest(unittest.TestCase):
-	"""A test case that tests compatibility functions, based on old
-	SecretStorage test."""
-
-	def __init__(self, *args, **kwargs):
-		unittest.TestCase.__init__(self, *args, **kwargs)
-		self.create_item = catch_deprecation_warnings(self, secretstorage.create_item)
-		self.get_items = catch_deprecation_warnings(self, secretstorage.get_items)
-		self.get_items_ids = catch_deprecation_warnings(self, secretstorage.get_items_ids)
-		self.get_item = catch_deprecation_warnings(self, secretstorage.get_item)
-		self.get_item_attributes = catch_deprecation_warnings(self, secretstorage.get_item_attributes)
-		self.delete_item = catch_deprecation_warnings(self, secretstorage.delete_item)
-
-	def setUp(self):
-		self.item_id = self.create_item('Test item', ATTRIBUTES, PASSWORD)
-
-	def test_get_items(self):
-		attrs, secret = self.get_items(ATTRIBUTES)[-1]
-		self.assertEqual(attrs['application'], 'secretstorage-test')
-		self.assertEqual(secret, PASSWORD)
-
-	def test_get_items_ids(self):
-		item_id = self.get_items_ids(ATTRIBUTES)[-1]
-		self.assertEqual(item_id, self.item_id)
-
-	def test_get_item(self):
-		attrs, secret = self.get_item(self.item_id)
-		self.assertEqual(attrs['application'], 'secretstorage-test')
-		self.assertEqual(secret, PASSWORD)
-
-	def test_get_item_attributes(self):
-		attrs = self.get_item_attributes(self.item_id)
-		self.assertEqual(attrs['application'], 'secretstorage-test')
-		self.assertEqual(attrs['attribute'], rand)
-
-	def tearDown(self):
-		self.delete_item(self.item_id)
-
-if __name__ == '__main__':
-	unittest.main()

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-secretstorage.git



More information about the Python-modules-commits mailing list