summaryrefslogtreecommitdiff
path: root/python-exponent-server-sdk.spec
diff options
context:
space:
mode:
Diffstat (limited to 'python-exponent-server-sdk.spec')
-rw-r--r--python-exponent-server-sdk.spec302
1 files changed, 302 insertions, 0 deletions
diff --git a/python-exponent-server-sdk.spec b/python-exponent-server-sdk.spec
new file mode 100644
index 0000000..8d92243
--- /dev/null
+++ b/python-exponent-server-sdk.spec
@@ -0,0 +1,302 @@
+%global _empty_manifest_terminate_build 0
+Name: python-exponent-server-sdk
+Version: 2.0.0
+Release: 1
+Summary: Expo Server SDK for Python
+License: MIT
+URL: https://github.com/expo/exponent-server-sdk-python
+Source0: https://mirrors.nju.edu.cn/pypi/web/packages/95/5a/263a29f6fdf0fc4c91bfe7bfa6ea6b124a279df4614a30005f59e9eeb5d6/exponent_server_sdk-2.0.0.tar.gz
+BuildArch: noarch
+
+Requires: python3-requests
+Requires: python3-six
+
+%description
+# exponent-server-sdk-python
+
+This repo is maintained by Expo's awesome community :heart_eyes:! So, if you have problems with the code in this repository, please feel free to open an issue, and make a PR. Thanks!
+
+## Installation
+
+```
+pip install exponent_server_sdk
+```
+
+## Usage
+
+Use to send push notifications to Exponent Experiences from a Python server.
+
+[Full documentation](https://docs.expo.io/versions/latest/guides/push-notifications#http2-api) on the API is available if you want to dive into the details.
+
+Here's an example on how to use this with retries and reporting via [pyrollbar](https://github.com/rollbar/pyrollbar).
+```python
+from exponent_server_sdk import (
+ DeviceNotRegisteredError,
+ PushClient,
+ PushMessage,
+ PushResponseError,
+ PushServerError,
+)
+from requests.exceptions import ConnectionError, HTTPError
+
+
+# Basic arguments. You should extend this function with the push features you
+# want to use, or simply pass in a `PushMessage` object.
+def send_push_message(token, message, extra=None):
+ try:
+ response = PushClient().publish(
+ PushMessage(to=token,
+ body=message,
+ data=extra))
+ except PushServerError as exc:
+ # Encountered some likely formatting/validation error.
+ rollbar.report_exc_info(
+ extra_data={
+ 'token': token,
+ 'message': message,
+ 'extra': extra,
+ 'errors': exc.errors,
+ 'response_data': exc.response_data,
+ })
+ raise
+ except (ConnectionError, HTTPError) as exc:
+ # Encountered some Connection or HTTP error - retry a few times in
+ # case it is transient.
+ rollbar.report_exc_info(
+ extra_data={'token': token, 'message': message, 'extra': extra})
+ raise self.retry(exc=exc)
+
+ try:
+ # We got a response back, but we don't know whether it's an error yet.
+ # This call raises errors so we can handle them with normal exception
+ # flows.
+ response.validate_response()
+ except DeviceNotRegisteredError:
+ # Mark the push token as inactive
+ from notifications.models import PushToken
+ PushToken.objects.filter(token=token).update(active=False)
+ except PushTicketError as exc:
+ # Encountered some other per-notification error.
+ rollbar.report_exc_info(
+ extra_data={
+ 'token': token,
+ 'message': message,
+ 'extra': extra,
+ 'push_response': exc.push_response._asdict(),
+ })
+ raise self.retry(exc=exc)
+```
+
+
+
+
+%package -n python3-exponent-server-sdk
+Summary: Expo Server SDK for Python
+Provides: python-exponent-server-sdk
+BuildRequires: python3-devel
+BuildRequires: python3-setuptools
+BuildRequires: python3-pip
+%description -n python3-exponent-server-sdk
+# exponent-server-sdk-python
+
+This repo is maintained by Expo's awesome community :heart_eyes:! So, if you have problems with the code in this repository, please feel free to open an issue, and make a PR. Thanks!
+
+## Installation
+
+```
+pip install exponent_server_sdk
+```
+
+## Usage
+
+Use to send push notifications to Exponent Experiences from a Python server.
+
+[Full documentation](https://docs.expo.io/versions/latest/guides/push-notifications#http2-api) on the API is available if you want to dive into the details.
+
+Here's an example on how to use this with retries and reporting via [pyrollbar](https://github.com/rollbar/pyrollbar).
+```python
+from exponent_server_sdk import (
+ DeviceNotRegisteredError,
+ PushClient,
+ PushMessage,
+ PushResponseError,
+ PushServerError,
+)
+from requests.exceptions import ConnectionError, HTTPError
+
+
+# Basic arguments. You should extend this function with the push features you
+# want to use, or simply pass in a `PushMessage` object.
+def send_push_message(token, message, extra=None):
+ try:
+ response = PushClient().publish(
+ PushMessage(to=token,
+ body=message,
+ data=extra))
+ except PushServerError as exc:
+ # Encountered some likely formatting/validation error.
+ rollbar.report_exc_info(
+ extra_data={
+ 'token': token,
+ 'message': message,
+ 'extra': extra,
+ 'errors': exc.errors,
+ 'response_data': exc.response_data,
+ })
+ raise
+ except (ConnectionError, HTTPError) as exc:
+ # Encountered some Connection or HTTP error - retry a few times in
+ # case it is transient.
+ rollbar.report_exc_info(
+ extra_data={'token': token, 'message': message, 'extra': extra})
+ raise self.retry(exc=exc)
+
+ try:
+ # We got a response back, but we don't know whether it's an error yet.
+ # This call raises errors so we can handle them with normal exception
+ # flows.
+ response.validate_response()
+ except DeviceNotRegisteredError:
+ # Mark the push token as inactive
+ from notifications.models import PushToken
+ PushToken.objects.filter(token=token).update(active=False)
+ except PushTicketError as exc:
+ # Encountered some other per-notification error.
+ rollbar.report_exc_info(
+ extra_data={
+ 'token': token,
+ 'message': message,
+ 'extra': extra,
+ 'push_response': exc.push_response._asdict(),
+ })
+ raise self.retry(exc=exc)
+```
+
+
+
+
+%package help
+Summary: Development documents and examples for exponent-server-sdk
+Provides: python3-exponent-server-sdk-doc
+%description help
+# exponent-server-sdk-python
+
+This repo is maintained by Expo's awesome community :heart_eyes:! So, if you have problems with the code in this repository, please feel free to open an issue, and make a PR. Thanks!
+
+## Installation
+
+```
+pip install exponent_server_sdk
+```
+
+## Usage
+
+Use to send push notifications to Exponent Experiences from a Python server.
+
+[Full documentation](https://docs.expo.io/versions/latest/guides/push-notifications#http2-api) on the API is available if you want to dive into the details.
+
+Here's an example on how to use this with retries and reporting via [pyrollbar](https://github.com/rollbar/pyrollbar).
+```python
+from exponent_server_sdk import (
+ DeviceNotRegisteredError,
+ PushClient,
+ PushMessage,
+ PushResponseError,
+ PushServerError,
+)
+from requests.exceptions import ConnectionError, HTTPError
+
+
+# Basic arguments. You should extend this function with the push features you
+# want to use, or simply pass in a `PushMessage` object.
+def send_push_message(token, message, extra=None):
+ try:
+ response = PushClient().publish(
+ PushMessage(to=token,
+ body=message,
+ data=extra))
+ except PushServerError as exc:
+ # Encountered some likely formatting/validation error.
+ rollbar.report_exc_info(
+ extra_data={
+ 'token': token,
+ 'message': message,
+ 'extra': extra,
+ 'errors': exc.errors,
+ 'response_data': exc.response_data,
+ })
+ raise
+ except (ConnectionError, HTTPError) as exc:
+ # Encountered some Connection or HTTP error - retry a few times in
+ # case it is transient.
+ rollbar.report_exc_info(
+ extra_data={'token': token, 'message': message, 'extra': extra})
+ raise self.retry(exc=exc)
+
+ try:
+ # We got a response back, but we don't know whether it's an error yet.
+ # This call raises errors so we can handle them with normal exception
+ # flows.
+ response.validate_response()
+ except DeviceNotRegisteredError:
+ # Mark the push token as inactive
+ from notifications.models import PushToken
+ PushToken.objects.filter(token=token).update(active=False)
+ except PushTicketError as exc:
+ # Encountered some other per-notification error.
+ rollbar.report_exc_info(
+ extra_data={
+ 'token': token,
+ 'message': message,
+ 'extra': extra,
+ 'push_response': exc.push_response._asdict(),
+ })
+ raise self.retry(exc=exc)
+```
+
+
+
+
+%prep
+%autosetup -n exponent-server-sdk-2.0.0
+
+%build
+%py3_build
+
+%install
+%py3_install
+install -d -m755 %{buildroot}/%{_pkgdocdir}
+if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
+if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
+if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
+if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
+pushd %{buildroot}
+if [ -d usr/lib ]; then
+ find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+if [ -d usr/lib64 ]; then
+ find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+if [ -d usr/bin ]; then
+ find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+if [ -d usr/sbin ]; then
+ find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+touch doclist.lst
+if [ -d usr/share/man ]; then
+ find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
+fi
+popd
+mv %{buildroot}/filelist.lst .
+mv %{buildroot}/doclist.lst .
+
+%files -n python3-exponent-server-sdk -f filelist.lst
+%dir %{python3_sitelib}/*
+
+%files help -f doclist.lst
+%{_docdir}/*
+
+%changelog
+* Mon Apr 10 2023 Python_Bot <Python_Bot@openeuler.org> - 2.0.0-1
+- Package Spec generated