From 67377b02378e1638ca8e23891244297ad8ea3d43 Mon Sep 17 00:00:00 2001 From: Sebastian Molenda Date: Tue, 13 Aug 2024 14:30:38 +0200 Subject: [PATCH 1/3] Additional example --- .../pubnub_asyncio/file_handling_async.py | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 examples/pubnub_asyncio/file_handling_async.py diff --git a/examples/pubnub_asyncio/file_handling_async.py b/examples/pubnub_asyncio/file_handling_async.py new file mode 100644 index 00000000..73c2b22b --- /dev/null +++ b/examples/pubnub_asyncio/file_handling_async.py @@ -0,0 +1,47 @@ +import os + + +from pubnub.pubnub_asyncio import PubNubAsyncio +from pubnub.pnconfiguration import PNConfiguration + + +config = PNConfiguration() +config.publish_key = os.environ.get('PN_KEY_PUBLISH') +config.subscribe_request_timeout = 10 +config.subscribe_key = os.environ.get('PN_KEY_SUBSCRIBE') +config.enable_subscribe = False +config.uuid = 'demo' + +channel = 'file-channel' +pubnub = PubNubAsyncio(config) +sample_path = f"{os.getcwd()}/examples/native_sync/sample.gif" + + +def callback(response, *args): + print(f"Sent file: {response.result.name} with id: {response.result.file_id}," + f" at timestamp: {response.result.timestamp}") + + +with open(sample_path, 'rb') as sample_file: + sample_file.seek(0) + pubnub.send_file() \ + .channel(channel) \ + .file_name("sample.gif") \ + .message({"test_message": "test"}) \ + .file_object(sample_file) \ + .pn_async(callback) + +file_list_response = pubnub.list_files().channel(channel).sync() +print(f"Found {len(file_list_response.result.data)} files:") + +for pos in file_list_response.result.data: + print(f" {pos['name']} with id: {pos['id']}") + ext = pos['name'].replace('sample', '') + download_url = pubnub.get_file_url().channel(channel).file_id(pos['id']).file_name(pos['name']).sync() + print(f' Download url: {download_url.result.file_url}') + download_file = pubnub.download_file().channel(channel).file_id(pos['id']).file_name(pos['name']).sync() + fw = open(f"{os.getcwd()}/examples/native_sync/out-{pos['id']}{ext}", 'wb') + fw.write(download_file.result.data) + print(f" file saved as {os.getcwd()}/examples/native_sync/out-{pos['id']}{ext}\n") + pubnub.delete_file().channel(channel).file_id(pos['id']).file_name(pos['name']).sync() + print(' File deleted from storage') From f041f51e5d0fadafd4b6ebdee3decc573c5e935f Mon Sep 17 00:00:00 2001 From: Sebastian Molenda Date: Tue, 13 Aug 2024 15:06:31 +0200 Subject: [PATCH 2/3] ENV key names fixed --- examples/pubnub_asyncio/file_handling_async.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/pubnub_asyncio/file_handling_async.py b/examples/pubnub_asyncio/file_handling_async.py index 73c2b22b..6cd1285e 100644 --- a/examples/pubnub_asyncio/file_handling_async.py +++ b/examples/pubnub_asyncio/file_handling_async.py @@ -6,11 +6,11 @@ config = PNConfiguration() -config.publish_key = os.environ.get('PN_KEY_PUBLISH') +config.publish_key = os.environ.get('PUBLISH_KEY', 'demo') config.subscribe_request_timeout = 10 -config.subscribe_key = os.environ.get('PN_KEY_SUBSCRIBE') +config.subscribe_key = os.environ.get('SUBSCRIBE_KEY', 'demo') config.enable_subscribe = False -config.uuid = 'demo' +config.uuid = 'example' channel = 'file-channel' pubnub = PubNubAsyncio(config) From 7cfd8072c74e12445318a385420d3c985657c536 Mon Sep 17 00:00:00 2001 From: PubNub Release Bot <120067856+pubnub-release-bot@users.noreply.github.com> Date: Tue, 13 Aug 2024 13:26:35 +0000 Subject: [PATCH 3/3] PubNub SDK v8.1.0 release. --- .pubnub.yml | 17 +++++++++++++---- CHANGELOG.md | 12 ++++++++++++ pubnub/pubnub_core.py | 2 +- setup.py | 2 +- 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/.pubnub.yml b/.pubnub.yml index bc035c3c..0b71126e 100644 --- a/.pubnub.yml +++ b/.pubnub.yml @@ -1,5 +1,5 @@ name: python -version: 8.0.0 +version: 8.1.0 schema: 1 scm: github.com/pubnub/python sdks: @@ -18,7 +18,7 @@ sdks: distributions: - distribution-type: library distribution-repository: package - package-name: pubnub-8.0.0 + package-name: pubnub-8.1.0 location: https://pypi.org/project/pubnub/ supported-platforms: supported-operating-systems: @@ -97,8 +97,8 @@ sdks: - distribution-type: library distribution-repository: git release - package-name: pubnub-8.0.0 - location: https://github.com/pubnub/python/releases/download/v8.0.0/pubnub-8.0.0.tar.gz + package-name: pubnub-8.1.0 + location: https://github.com/pubnub/python/releases/download/v8.1.0/pubnub-8.1.0.tar.gz supported-platforms: supported-operating-systems: Linux: @@ -169,6 +169,15 @@ sdks: license-url: https://github.com/aio-libs/aiohttp/blob/master/LICENSE.txt is-required: Required changelog: + - date: 2024-08-13 + version: v8.1.0 + changes: + - type: feature + text: "Option to lock PNConfiguration mutability. Note that mutable config will be deprecated in future major releases." + - type: bug + text: "Fix for routing crypto module if custom one was defined." + - type: improvement + text: "Additional Examples." - date: 2024-05-09 version: v8.0.0 changes: diff --git a/CHANGELOG.md b/CHANGELOG.md index 49b10d02..322f4eb7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,15 @@ +## v8.1.0 +August 13 2024 + +#### Added +- Option to lock PNConfiguration mutability. Note that mutable config will be deprecated in future major releases. + +#### Fixed +- Fix for routing crypto module if custom one was defined. + +#### Modified +- Additional Examples. + ## v8.0.0 May 09 2024 diff --git a/pubnub/pubnub_core.py b/pubnub/pubnub_core.py index e36abca1..60288671 100644 --- a/pubnub/pubnub_core.py +++ b/pubnub/pubnub_core.py @@ -90,7 +90,7 @@ class PubNubCore: """A base class for PubNub Python API implementations""" - SDK_VERSION = "8.0.0" + SDK_VERSION = "8.1.0" SDK_NAME = "PubNub-Python" TIMESTAMP_DIVIDER = 1000 diff --git a/setup.py b/setup.py index 3d9105ba..b0ab0009 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup( name='pubnub', - version='8.0.0', + version='8.1.0', description='PubNub Real-time push service in the cloud', author='PubNub', author_email='support@pubnub.com',