Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
7df27a3
async rename to pn_async
QSDdean Sep 11, 2018
0c77d53
Update .pubnub.yml
qsoftdevelopment Sep 11, 2018
72927e7
Update CHANGELOG.md
qsoftdevelopment Sep 11, 2018
6bf2ab9
Prepare for release 4.1.2
qsoftdevelopment Sep 20, 2018
2b3a4fa
Fixed yml formatting issue
crimsonred Sep 27, 2018
b73c0e4
Merge branch 'master' into develop
Sep 27, 2018
ab5b43e
Check if response is JSON.
Feb 22, 2019
785cd2c
Add support for message count API.
Feb 22, 2019
f9f2fe4
timetoken -> channel_timetokens
Feb 22, 2019
fa91b48
Change endpoint name to mc.
Feb 22, 2019
2995b67
Use proper parameter name.
Feb 22, 2019
62da02b
Convert ints to strings.
Feb 22, 2019
289f8b6
Add PNMessageCountResult class.
Feb 22, 2019
34bab37
history_with_messages -> message_count.
Feb 24, 2019
d9c68d5
Add functional tests.
Feb 24, 2019
e9ad2d8
Add integration tests.
Feb 24, 2019
66df45f
Remove unused imports.
Feb 24, 2019
bcd13ce
Extract common PNConfiguration.
Feb 24, 2019
ef8877f
message_count -> message_counts
Feb 24, 2019
26359f1
Fix flake8 errors.
Feb 24, 2019
af8bb2b
Use yield from instead of async/await for compat.
Feb 24, 2019
d7fd7ac
Pin testing deps to avoid bugs.
Feb 24, 2019
135180e
Remove event_loop fixture.
Feb 24, 2019
b006a7c
Remove support for Python 3.3.
Feb 24, 2019
e49ba70
Use lower timetoken for tests.
Feb 24, 2019
e9f217d
Use VCR.py to create deterministic tests.
Feb 24, 2019
9bdbc0d
Remove tests which cannot be recorded.
Feb 24, 2019
4d089f5
Pin pytest-cov to specific version on specific platforms.
Feb 24, 2019
759300b
Specify an exact py.test version to use.
Feb 24, 2019
7b363ea
Lower py.test version for Python 3.4.
Feb 24, 2019
7761fa4
Appease codacy check.
Feb 25, 2019
4c68ec0
Prepare for release 4.1.3.
Feb 25, 2019
3b4ff85
Merge pull request #67 from QSDZvonimir/develop
qsoftdevelopment Feb 27, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions 10 .pubnub.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
name: python
version: 4.1.2
version: 4.1.3
schema: 1
scm: github.com/pubnub/python
changelog:
- version: v4.1.3
date: Feb 25, 2019
changes:
- type: improvement
text: implement history Message Counts
- version: v4.1.2
date: Sep 20, 2018
changes:
Expand Down Expand Up @@ -140,6 +145,7 @@ features:
- STORAGE-INCLUDE-TIMETOKEN
- STORAGE-START-END
- STORAGE-COUNT
- STORAGE-MESSAGE-COUNT
time:
- TIME-TIME
subscribe:
Expand All @@ -161,7 +167,6 @@ supported-platforms:
- Windows 7 or later, amd64, 386
editors:
- python 2.7.13
- python 3.3.6
- python 3.4.5
- python 3.5.2
- python 3.6.0
Expand All @@ -175,7 +180,6 @@ supported-platforms:
- Windows 7 or later, amd64, 386
editors:
- python 2.7.13
- python 3.3.6
- python 3.4.5
- python 3.5.2
- python 3.6.0
Expand Down
1 change: 0 additions & 1 deletion 1 .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
language: python
python:
- "2.7"
- "3.3"
- "3.4"
- "3.5"
- "3.6"
Expand Down
5 changes: 5 additions & 0 deletions 5 CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## [4.1.3](https://github.com/pubnub/python/tree/v4.1.3)

[Full Changelog](https://github.com/pubnub/python/compare/v4.1.2...v4.1.3)

- 🐛Implement history message counts

## [4.1.2](https://github.com/pubnub/python/tree/v4.1.2)

Expand Down
2 changes: 1 addition & 1 deletion 2 DEVELOPER.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Developers manual

## Supported Python versions
We support Python 2.7 and >=3.3
We support Python 2.7 and >=3.4

## Supported platforms
We maintain and test our SDK using Travis.CI and Ubuntu.
Expand Down
2 changes: 1 addition & 1 deletion 2 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![PyPI](https://img.shields.io/pypi/pyversions/pubnub.svg)](https://pypi.python.org/pypi/pubnub/)
[![Docs](https://img.shields.io/badge/docs-online-blue.svg)](https://www.pubnub.com/docs/python/pubnub-python-sdk-v4)

The SDK supports Python 2.7, 3.3, 3.4, 3.5, 3.6, 3.7 and pypy.
The SDK supports Python 2.7, 3.4, 3.5, 3.6, 3.7 and pypy.

## Documentation

Expand Down
1 change: 1 addition & 0 deletions 1 bandit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
skips: ['B101']
2 changes: 1 addition & 1 deletion 2 examples/twisted/basic_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def main():
def my_publish_callback(result, status):
# Check whether request successfully completed or not
if not status.is_error():
envelope = result # NOQA:W292
envelope = result # noqa
pass # Message successfully published to specified channel.
else:
pass # Handle message publish error. Check 'category' property to find out possible issue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ def custom_params(self):
return {'add': utils.join_items(self._channels)}

def build_path(self):
return AddChannelToChannelGroup.ADD_PATH % (
self.pubnub.config.subscribe_key, utils.url_encode(self._channel_group))
return AddChannelToChannelGroup.ADD_PATH % (
self.pubnub.config.subscribe_key, utils.url_encode(self._channel_group))

def http_method(self):
return HttpMethod.GET
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ def custom_params(self):
return {}

def build_path(self):
return ListChannelsInChannelGroup.LIST_PATH % (
self.pubnub.config.subscribe_key, utils.url_encode(self._channel_group))
return ListChannelsInChannelGroup.LIST_PATH % (
self.pubnub.config.subscribe_key, utils.url_encode(self._channel_group))

def http_method(self):
return HttpMethod.GET
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ def custom_params(self):
return {'remove': utils.join_items(self._channels)}

def build_path(self):
return RemoveChannelFromChannelGroup.REMOVE_PATH % (
self.pubnub.config.subscribe_key, utils.url_encode(self._channel_group))
return RemoveChannelFromChannelGroup.REMOVE_PATH % (
self.pubnub.config.subscribe_key, utils.url_encode(self._channel_group))

def http_method(self):
return HttpMethod.GET
Expand Down
4 changes: 2 additions & 2 deletions 4 pubnub/endpoints/channel_groups/remove_channel_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ def custom_params(self):
return {}

def build_path(self):
return RemoveChannelGroup.REMOVE_PATH % (
self.pubnub.config.subscribe_key, utils.url_encode(self._channel_group))
return RemoveChannelGroup.REMOVE_PATH % (
self.pubnub.config.subscribe_key, utils.url_encode(self._channel_group))

def http_method(self):
return HttpMethod.GET
Expand Down
2 changes: 1 addition & 1 deletion 2 pubnub/endpoints/endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def validate_secret_key(self):
raise PubNubException(pn_error=PNERR_SECRET_KEY_MISSING)

def validate_channel(self):
if self._channel is None or len(self._channel) is 0:
if self._channel is None or len(self._channel) == 0:
raise PubNubException(pn_error=PNERR_CHANNEL_MISSING)

def validate_channels_and_groups(self):
Expand Down
8 changes: 4 additions & 4 deletions 8 pubnub/endpoints/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ def custom_params(self):
return params

def build_path(self):
return History.HISTORY_PATH % (
self.pubnub.config.subscribe_key,
utils.url_encode(self._channel)
)
return History.HISTORY_PATH % (
self.pubnub.config.subscribe_key,
utils.url_encode(self._channel)
)

def http_method(self):
return HttpMethod.GET
Expand Down
8 changes: 4 additions & 4 deletions 8 pubnub/endpoints/history_delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ def custom_params(self):
return params

def build_path(self):
return HistoryDelete.HISTORY_DELETE_PATH % (
self.pubnub.config.subscribe_key,
utils.url_encode(self._channel)
)
return HistoryDelete.HISTORY_DELETE_PATH % (
self.pubnub.config.subscribe_key,
utils.url_encode(self._channel)
)

def http_method(self):
return HttpMethod.DELETE
Expand Down
66 changes: 66 additions & 0 deletions 66 pubnub/endpoints/message_count.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
from pubnub import utils
from pubnub.endpoints.endpoint import Endpoint
from pubnub.enums import HttpMethod, PNOperationType
from pubnub.exceptions import PubNubException
from pubnub.models.consumer.message_count import PNMessageCountResult


class MessageCount(Endpoint):
MESSAGE_COUNT_PATH = '/v3/history/sub-key/%s/message-counts/%s'

def __init__(self, pubnub):
Endpoint.__init__(self, pubnub)
self._channel = []
self._channels_timetoken = []

def channel(self, channel):
utils.extend_list(self._channel, channel)
return self

def channel_timetokens(self, timetokens):
timetokens = [str(item) for item in timetokens]
utils.extend_list(self._channels_timetoken, timetokens)
return self

def custom_params(self):
params = {}
if len(self._channels_timetoken) > 0:
if len(self._channels_timetoken) > 1:
params['channelsTimetoken'] = utils.join_items(self._channels_timetoken)
else:
params['timetoken'] = self._channels_timetoken[0]
return params

def build_path(self):
return MessageCount.MESSAGE_COUNT_PATH % (
self.pubnub.config.subscribe_key,
utils.join_channels(self._channel)
)

def http_method(self):
return HttpMethod.GET

def is_auth_required(self):
return True

def validate_params(self):
self.validate_subscribe_key()
self.validate_channel()

if len(self._channels_timetoken) != len(self._channel):
raise PubNubException('The number of channels and the number of timetokens do not match.')

def create_response(self, result): # pylint: disable=W0221
return PNMessageCountResult(result)

def request_timeout(self):
return self.pubnub.config.non_subscribe_request_timeout

def connect_timeout(self):
return self.pubnub.config.connect_timeout

def operation_type(self):
return PNOperationType.PNMessageCountOperation

def name(self):
return "Message Count"
10 changes: 5 additions & 5 deletions 10 pubnub/endpoints/presence/get_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ def custom_params(self):
return params

def build_path(self):
return GetState.GET_STATE_PATH % (
self.pubnub.config.subscribe_key,
utils.join_channels(self._channels),
utils.url_encode(self.pubnub.uuid)
)
return GetState.GET_STATE_PATH % (
self.pubnub.config.subscribe_key,
utils.join_channels(self._channels),
utils.url_encode(self.pubnub.uuid)
)

def http_method(self):
return HttpMethod.GET
Expand Down
2 changes: 1 addition & 1 deletion 2 pubnub/endpoints/presence/leave.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def custom_params(self):
return params

def build_path(self):
return Leave.LEAVE_PATH % (self.pubnub.config.subscribe_key, utils.join_channels(self._channels))
return Leave.LEAVE_PATH % (self.pubnub.config.subscribe_key, utils.join_channels(self._channels))

def http_method(self):
return HttpMethod.GET
Expand Down
12 changes: 6 additions & 6 deletions 12 pubnub/endpoints/presence/set_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ def custom_params(self):
return params

def build_path(self):
return SetState.SET_STATE_PATH % (
self.pubnub.config.subscribe_key,
utils.join_channels(self._channels),
utils.url_encode(self.pubnub.uuid)
)
return SetState.SET_STATE_PATH % (
self.pubnub.config.subscribe_key,
utils.join_channels(self._channels),
utils.url_encode(self.pubnub.uuid)
)

def http_method(self):
return HttpMethod.GET
Expand All @@ -66,7 +66,7 @@ def validate_params(self):
raise PubNubException(pn_error=PNERR_STATE_MISSING)

def create_response(self, envelope):
if 'status' in envelope and envelope['status'] is 200:
if 'status' in envelope and envelope['status'] == 200:
return PNSetStateResult(envelope['payload'])
else:
return envelope
Expand Down
4 changes: 2 additions & 2 deletions 4 pubnub/endpoints/push/add_channels_to_push.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ def custom_params(self):
return params

def build_path(self):
return AddChannelsToPush.ADD_PATH % (
self.pubnub.config.subscribe_key, self._device_id)
return AddChannelsToPush.ADD_PATH % (
self.pubnub.config.subscribe_key, self._device_id)

def http_method(self):
return HttpMethod.GET
Expand Down
4 changes: 2 additions & 2 deletions 4 pubnub/endpoints/push/list_push_provisions.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ def custom_params(self):
return params

def build_path(self):
return ListPushProvisions.LIST_PATH % (
self.pubnub.config.subscribe_key, self._device_id)
return ListPushProvisions.LIST_PATH % (
self.pubnub.config.subscribe_key, self._device_id)

def http_method(self):
return HttpMethod.GET
Expand Down
4 changes: 2 additions & 2 deletions 4 pubnub/endpoints/push/remove_channels_from_push.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ def custom_params(self):
return params

def build_path(self):
return RemoveChannelsFromPush.REMOVE_PATH % (
self.pubnub.config.subscribe_key, self._device_id)
return RemoveChannelsFromPush.REMOVE_PATH % (
self.pubnub.config.subscribe_key, self._device_id)

def http_method(self):
return HttpMethod.GET
Expand Down
4 changes: 2 additions & 2 deletions 4 pubnub/endpoints/push/remove_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ def custom_params(self):
return params

def build_path(self):
return RemoveDeviceFromPush.REMOVE_PATH % (
self.pubnub.config.subscribe_key, self._device_id)
return RemoveDeviceFromPush.REMOVE_PATH % (
self.pubnub.config.subscribe_key, self._device_id)

def http_method(self):
return HttpMethod.GET
Expand Down
2 changes: 1 addition & 1 deletion 2 pubnub/endpoints/time.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def custom_params(self):
return {}

def build_path(self):
return Time.TIME_PATH
return Time.TIME_PATH

def http_method(self):
return HttpMethod.GET
Expand Down
1 change: 1 addition & 0 deletions 1 pubnub/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class PNOperationType(object):
PNAccessManagerGrant = 21
PNAccessManagerRevoke = 22
PNHistoryDeleteOperation = 23
PNMessageCountOperation = 24


class PNHeartbeatNotificationOptions(object):
Expand Down
1 change: 1 addition & 0 deletions 1 pubnub/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@ def endpoint_name_for_operation(operation_type):

PNOperationType.PNHistoryOperation: 'hist',
PNOperationType.PNHistoryDeleteOperation: 'hist',
PNOperationType.PNMessageCountOperation: 'mc',

PNOperationType.PNUnsubscribeOperation: 'pres',
PNOperationType.PNWhereNowOperation: 'pres',
Expand Down
12 changes: 12 additions & 0 deletions 12 pubnub/models/consumer/message_count.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class PNMessageCountResult(object):
def __init__(self, result):
"""
Representation of message count server response

:param result: result of message count operation
"""
self._result = result
self.channels = result['channels']

def __str__(self):
return "Message count for channels: {}".format(self.channels)
2 changes: 1 addition & 1 deletion 2 pubnub/pubnub_asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ def _perform_heartbeat_loop(self):
if heartbeat_verbosity == PNHeartbeatNotificationOptions.ALL:
self._listener_manager.announce_status(envelope.status)

except PubNubAsyncioException as e:
except PubNubAsyncioException:
pass
# TODO: check correctness
# if e.status is not None and e.status.category == PNStatusCategory.PNTimeoutCategory:
Expand Down
4 changes: 4 additions & 0 deletions 4 pubnub/pubnub_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from .endpoints.presence.here_now import HereNow
from .endpoints.presence.where_now import WhereNow
from .endpoints.history_delete import HistoryDelete
from .endpoints.message_count import MessageCount

from .endpoints.push.add_channels_to_push import AddChannelsToPush
from .endpoints.push.remove_channels_from_push import RemoveChannelsFromPush
Expand Down Expand Up @@ -157,6 +158,9 @@ def remove_device_from_push(self):
def history(self):
return History(self)

def message_counts(self):
return MessageCount(self)

def time(self):
return Time(self)

Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.