From 84e64d49bfbf66b34b89bc909416bdf728e191e3 Mon Sep 17 00:00:00 2001 From: Scott Conway Date: Fri, 26 Jan 2018 10:42:24 -0500 Subject: [PATCH] Add DeprecationWarnings to all deprecated functions --- matrix_client/api.py | 6 ++++++ matrix_client/client.py | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/matrix_client/api.py b/matrix_client/api.py index 6c17f878..23ff56c6 100644 --- a/matrix_client/api.py +++ b/matrix_client/api.py @@ -14,10 +14,14 @@ # limitations under the License. import json +import logging import requests from time import time, sleep from .errors import MatrixError, MatrixRequestError, MatrixHttpLibError +logger = logging.getLogger(__name__) +logging.captureWarnings(True) + try: from urllib import quote except ImportError: @@ -62,6 +66,7 @@ def initial_sync(self, limit=1): Args: limit (int): The limit= param to provide. """ + logger.warning('initial_sync is deprecated. Use sync instead', DeprecationWarning) return self._send("GET", "/initialSync", query_params={"limit": limit}) def sync(self, since=None, timeout_ms=30000, filter=None, @@ -192,6 +197,7 @@ def event_stream(self, from_token, timeout=30000): from_token (str): The 'from' query parameter. timeout (int): Optional. The 'timeout' query parameter. """ + logger.warning('event_stream is deprecated. Use sync instead', DeprecationWarning) path = "/events" return self._send( "GET", path, query_params={ diff --git a/matrix_client/client.py b/matrix_client/client.py index 3ea1dc03..d2ef6407 100644 --- a/matrix_client/client.py +++ b/matrix_client/client.py @@ -24,7 +24,7 @@ import sys logger = logging.getLogger(__name__) - +logging.captureWarnings(True) # Cache constants used when instantiating Matrix Client to specify level of caching class CACHE(Enum): @@ -398,6 +398,7 @@ def listen_for_events(self, timeout_ms=30000): timeout_ms (int): How long to poll the Home Server for before retrying. """ + logger.warning("listen_for_events is deprecated", DeprecationWarning) self._sync(timeout_ms) def listen_forever(self, timeout_ms=30000, exception_handler=None):