diff options
author | Kali Kaneko <kali@leap.se> | 2015-09-24 15:18:46 -0400 |
---|---|---|
committer | Kali Kaneko <kali@leap.se> | 2015-09-24 15:18:46 -0400 |
commit | fdd3382169d39abd00c035a5be11b20c6fdc588d (patch) | |
tree | e9598a74b9016f32cf34f858dd4ef76a788ced2e | |
parent | 56724056f95e3d908c3fd11840cf62e64afb9e0f (diff) | |
parent | d3519a062ea6924fa6b6b5cb4d804b5a39eb249f (diff) |
Merge tag '0.4.3' into debian/experimental
Tag leap.common version 0.4.3
-rw-r--r-- | CHANGELOG | 3 | ||||
-rw-r--r-- | README.rst | 6 | ||||
-rw-r--r-- | setup.cfg | 4 | ||||
-rw-r--r-- | setup.py | 11 | ||||
-rw-r--r-- | src/leap/common/events/__init__.py | 26 | ||||
-rw-r--r-- | src/leap/common/events/client.py | 13 | ||||
-rw-r--r-- | src/leap/common/events/txclient.py | 2 |
7 files changed, 44 insertions, 21 deletions
@@ -1,3 +1,6 @@ +0.4.3 Sep 22, 2015: + o Expose async methods for events. Closes: #7274 + 0.4.2 Aug 26, 2015: o Add http request timeout. Related to #7234. o Add a flag to disable events framework. Closes: #7259 @@ -1,8 +1,10 @@ leap.common =========== -.. image:: https://pypip.in/v/leap.common/badge.png - :target: https://crate.io/packages/leap.common +.. image:: https://badge.fury.io/py/leap.common.svg + :target: http://badge.fury.io/py/leap.common +.. image:: https://img.shields.io/pypi/dm/leap.common.svg + :target: http://badge.fury.io/py/leap.common A collection of shared utils used by the several python LEAP subprojects. @@ -7,9 +7,9 @@ tag_svn_revision = 0 test = trial [pep8] -exclude = versioneer.py,_version.py,*.egg,build,docs +exclude = versioneer.py,_version.py,*.egg,build,dist,docs ignore = E731 [flake8] -exclude = versioneer.py,_version.py,*.egg,build,docs +exclude = versioneer.py,_version.py,*.egg,build,dist,docs ignore = E731 @@ -19,9 +19,9 @@ setup file for leap.common """ import re from setuptools import setup, find_packages +from setuptools import Command from pkg import utils -parsed_reqs = utils.parse_requirements() import versioneer versioneer.versionfile_source = 'src/leap/common/_version.py' @@ -29,6 +29,8 @@ versioneer.versionfile_build = 'leap/common/_version.py' versioneer.tag_prefix = '' # tags are like 1.2.0 versioneer.parentdir_prefix = 'leap.common-' +parsed_reqs = utils.parse_requirements() + tests_requirements = [ 'mock', ] @@ -61,7 +63,6 @@ if len(_version_short) > 0: DOWNLOAD_URL = DOWNLOAD_BASE % VERSION_SHORT cmdclass = versioneer.get_cmdclass() -from setuptools import Command class freeze_debianver(Command): @@ -130,11 +131,11 @@ setup( package_data={'': ['*.pem']}, # For now, we do not exclude tests because of the circular dependency # between leap.common and leap.soledad. - #packages=find_packages('src', exclude=['leap.common.tests']), + # packages=find_packages('src', exclude=['leap.common.tests']), packages=find_packages('src'), test_suite='leap.common.tests', install_requires=parsed_reqs, - #dependency_links=dependency_links, + # dependency_links=dependency_links, tests_require=tests_requirements, include_package_data=True, zip_safe=False, @@ -143,6 +144,6 @@ setup( # needed for leap.common.http # service_identity needed for propper hostname identification, # see http://twistedmatrix.com/documents/current/core/howto/ssl.html - 'Twisted': ["Twisted>=14.0.2", "service_identity", "zope.interface"] + 'Twisted': ["Twisted>=14.0.2", "service_identity", "zope.interface"] }, ) diff --git a/src/leap/common/events/__init__.py b/src/leap/common/events/__init__.py index 87ed8ae..f9ad5fa 100644 --- a/src/leap/common/events/__init__.py +++ b/src/leap/common/events/__init__.py @@ -39,7 +39,9 @@ import logging import argparse from leap.common.events import client +from leap.common.events import txclient from leap.common.events import server +from leap.common.events import flags from leap.common.events.flags import set_events_enabled from leap.common.events import catalog @@ -77,7 +79,13 @@ def register(event, callback, uid=None, replace=False): :raises CallbackAlreadyRegistered: when there's already a callback identified by the given uid and replace is False. """ - return client.register(event, callback, uid, replace) + if flags.EVENTS_ENABLED: + return client.register(event, callback, uid, replace) + + +def register_async(event, callback, uid=None, replace=False): + if flags.EVENTS_ENABLED: + return txclient.register(event, callback, uid, replace) def unregister(event, uid=None): @@ -92,7 +100,13 @@ def unregister(event, uid=None): :param uid: The callback uid. :type uid: str """ - return client.unregister(event, uid) + if flags.EVENTS_ENABLED: + return client.unregister(event, uid) + + +def unregister_async(event, uid=None): + if flags.EVENTS_ENABLED: + return txclient.unregister(event, uid) def emit(event, *content): @@ -104,7 +118,13 @@ def emit(event, *content): :param content: The content of the event. :type content: list """ - return client.emit(event, *content) + if flags.EVENTS_ENABLED: + return client.emit(event, *content) + + +def emit_async(event, *content): + if flags.EVENTS_ENABLED: + return txclient.emit(event, *content) if __name__ == "__main__": diff --git a/src/leap/common/events/client.py b/src/leap/common/events/client.py index e085f5b..e38e9d3 100644 --- a/src/leap/common/events/client.py +++ b/src/leap/common/events/client.py @@ -465,7 +465,7 @@ class EventsClientThread(threading.Thread, EventsClient): Make sure the events client thread is started. """ with self._lock: - if flags.EVENTS_ENABLED and not self.is_alive(): + if not self.is_alive(): self.daemon = True self.start() self._initialized.wait() @@ -508,9 +508,8 @@ def register(event, callback, uid=None, replace=False): :raises CallbackAlreadyRegisteredError: when there's already a callback identified by the given uid and replace is False. """ - if flags.EVENTS_ENABLED: - return EventsClientThread.instance().register( - event, callback, uid=uid, replace=replace) + return EventsClientThread.instance().register( + event, callback, uid=uid, replace=replace) def unregister(event, uid=None): @@ -525,8 +524,7 @@ def unregister(event, uid=None): :param uid: The callback uid. :type uid: str """ - if flags.EVENTS_ENABLED: - return EventsClientThread.instance().unregister(event, uid=uid) + return EventsClientThread.instance().unregister(event, uid=uid) def emit(event, *content): @@ -538,8 +536,7 @@ def emit(event, *content): :param content: The content of the event. :type content: list """ - if flags.EVENTS_ENABLED: - return EventsClientThread.instance().emit(event, *content) + return EventsClientThread.instance().emit(event, *content) def instance(): diff --git a/src/leap/common/events/txclient.py b/src/leap/common/events/txclient.py index dfd0533..f3c183e 100644 --- a/src/leap/common/events/txclient.py +++ b/src/leap/common/events/txclient.py @@ -35,7 +35,7 @@ from leap.common.events.client import EventsClient from leap.common.events.client import configure_client from leap.common.events.server import EMIT_ADDR from leap.common.events.server import REG_ADDR -from leap.common.events import catalog +from leap.common.events import catalog, flags logger = logging.getLogger(__name__) |