diff options
author | CoprDistGit <infra@openeuler.org> | 2023-05-05 08:12:40 +0000 |
---|---|---|
committer | CoprDistGit <infra@openeuler.org> | 2023-05-05 08:12:40 +0000 |
commit | 49edd1477a5b1ae196753cbb099fbd622d185e8b (patch) | |
tree | f524942d8285b3783550825fc99c8bb1c17ee074 | |
parent | 8725787c3a55f4b1c84ea3d9f661bbdaf39b2e71 (diff) |
automatic import of python-dj-whispereropeneuler20.03
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | python-dj-whisperer.spec | 402 | ||||
-rw-r--r-- | sources | 1 |
3 files changed, 404 insertions, 0 deletions
@@ -0,0 +1 @@ +/dj-whisperer-0.2.13.tar.gz diff --git a/python-dj-whisperer.spec b/python-dj-whisperer.spec new file mode 100644 index 0000000..ad0f1a9 --- /dev/null +++ b/python-dj-whisperer.spec @@ -0,0 +1,402 @@ +%global _empty_manifest_terminate_build 0 +Name: python-dj-whisperer +Version: 0.2.13 +Release: 1 +Summary: Stay informed of it +License: MIT +URL: https://bitbucket.org/akinonteam/dj-whisperer +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/de/fa/f9abf65a118b530484dafa19f5be383b3724885e55c60139620bcf974dd6/dj-whisperer-0.2.13.tar.gz +BuildArch: noarch + + +%description +# Django Whisperer + +[](https://bitbucket.org/akinonteam/dj-whisperer/addon/pipelines/home) +[](https://dj-whisperer.readthedocs.io/en/latest/?badge=latest) + + + + + +Whisperer informs subscribed users via an URL when a specific event occurs. + +## Installation + +Installation using pip: + +``` +pip install dj-whisperer +``` + +`whisperer` package has to be added to `INSTALLED_APPS` and `migrate` command has to be run. + +```python +INSTALLED_APPS = ( + # other apps here... + 'whisperer', +) +``` + +## Sample Scenario + +Let's give an example using `Package` model. When an event occurs related to a package, subscribed users are gonna be informed. To do so, firstly which events to subscribe must be determined. In order to learn when a package created: + +```python +from django.db.models.signals import post_save +from whisperer.events import WhispererEvent, registry +from whisperer.tasks import deliver_event + +class PackageCreateEvent(WhispererEvent): + serializer_class = PackageSerializer + event_type = 'package-created' + +registry.register(PackageCreateEvent) + + +def signal_receiver(instance, created=False, **kwargs): + if created: + deliver_event(instance, 'package-created') + +post_save.connect(signal_receiver, Package) +``` + +When database transaction succeeds, in short when `transaction.on_commit()`, `deliver_event` must be triggered. +Subscribed users now can be informed that a package created if they have created a `Webhook`. + +```python +import requests + +requests.post( + url='https://your-app.com/whisperer/hooks/', + headers={ + 'Authorization': 'Token <secret-login-token>', + }, + json={ + 'event_type': 'package-created', + 'secret_key': 'secret', + 'target_url': 'https://example.com/', + } +) +``` + +When a package created, `uuid`, `type` & `data` passed through `PackageSerializer` will be posted to https://example.com/. + +```python +import requests + +requests.post( + url='https://example.com/', + headers={ + 'Content-Type': 'application/json', + 'X-Whisperer-Event': 'package-created', + }, + json={ + 'event': { + 'type': 'package-created', + 'uuid': 'da81e85139824c6187dd1e58a7d3f971', + }, + 'data': { + 'id': 61, + 'transfer_id': 49, + 'order_number': '248398923123', + '.....': '......', + } + } +) +``` + +In order to cancel the subscription: + +```python +import requests + +requests.delete( + url='https://your-app.com/whisperer/hooks/<webhook-id>/', + headers={ + 'Authorization': 'Token <secret-login-token>', + } +) +``` + + + + +%package -n python3-dj-whisperer +Summary: Stay informed of it +Provides: python-dj-whisperer +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-dj-whisperer +# Django Whisperer + +[](https://bitbucket.org/akinonteam/dj-whisperer/addon/pipelines/home) +[](https://dj-whisperer.readthedocs.io/en/latest/?badge=latest) + + + + + +Whisperer informs subscribed users via an URL when a specific event occurs. + +## Installation + +Installation using pip: + +``` +pip install dj-whisperer +``` + +`whisperer` package has to be added to `INSTALLED_APPS` and `migrate` command has to be run. + +```python +INSTALLED_APPS = ( + # other apps here... + 'whisperer', +) +``` + +## Sample Scenario + +Let's give an example using `Package` model. When an event occurs related to a package, subscribed users are gonna be informed. To do so, firstly which events to subscribe must be determined. In order to learn when a package created: + +```python +from django.db.models.signals import post_save +from whisperer.events import WhispererEvent, registry +from whisperer.tasks import deliver_event + +class PackageCreateEvent(WhispererEvent): + serializer_class = PackageSerializer + event_type = 'package-created' + +registry.register(PackageCreateEvent) + + +def signal_receiver(instance, created=False, **kwargs): + if created: + deliver_event(instance, 'package-created') + +post_save.connect(signal_receiver, Package) +``` + +When database transaction succeeds, in short when `transaction.on_commit()`, `deliver_event` must be triggered. +Subscribed users now can be informed that a package created if they have created a `Webhook`. + +```python +import requests + +requests.post( + url='https://your-app.com/whisperer/hooks/', + headers={ + 'Authorization': 'Token <secret-login-token>', + }, + json={ + 'event_type': 'package-created', + 'secret_key': 'secret', + 'target_url': 'https://example.com/', + } +) +``` + +When a package created, `uuid`, `type` & `data` passed through `PackageSerializer` will be posted to https://example.com/. + +```python +import requests + +requests.post( + url='https://example.com/', + headers={ + 'Content-Type': 'application/json', + 'X-Whisperer-Event': 'package-created', + }, + json={ + 'event': { + 'type': 'package-created', + 'uuid': 'da81e85139824c6187dd1e58a7d3f971', + }, + 'data': { + 'id': 61, + 'transfer_id': 49, + 'order_number': '248398923123', + '.....': '......', + } + } +) +``` + +In order to cancel the subscription: + +```python +import requests + +requests.delete( + url='https://your-app.com/whisperer/hooks/<webhook-id>/', + headers={ + 'Authorization': 'Token <secret-login-token>', + } +) +``` + + + + +%package help +Summary: Development documents and examples for dj-whisperer +Provides: python3-dj-whisperer-doc +%description help +# Django Whisperer + +[](https://bitbucket.org/akinonteam/dj-whisperer/addon/pipelines/home) +[](https://dj-whisperer.readthedocs.io/en/latest/?badge=latest) + + + + + +Whisperer informs subscribed users via an URL when a specific event occurs. + +## Installation + +Installation using pip: + +``` +pip install dj-whisperer +``` + +`whisperer` package has to be added to `INSTALLED_APPS` and `migrate` command has to be run. + +```python +INSTALLED_APPS = ( + # other apps here... + 'whisperer', +) +``` + +## Sample Scenario + +Let's give an example using `Package` model. When an event occurs related to a package, subscribed users are gonna be informed. To do so, firstly which events to subscribe must be determined. In order to learn when a package created: + +```python +from django.db.models.signals import post_save +from whisperer.events import WhispererEvent, registry +from whisperer.tasks import deliver_event + +class PackageCreateEvent(WhispererEvent): + serializer_class = PackageSerializer + event_type = 'package-created' + +registry.register(PackageCreateEvent) + + +def signal_receiver(instance, created=False, **kwargs): + if created: + deliver_event(instance, 'package-created') + +post_save.connect(signal_receiver, Package) +``` + +When database transaction succeeds, in short when `transaction.on_commit()`, `deliver_event` must be triggered. +Subscribed users now can be informed that a package created if they have created a `Webhook`. + +```python +import requests + +requests.post( + url='https://your-app.com/whisperer/hooks/', + headers={ + 'Authorization': 'Token <secret-login-token>', + }, + json={ + 'event_type': 'package-created', + 'secret_key': 'secret', + 'target_url': 'https://example.com/', + } +) +``` + +When a package created, `uuid`, `type` & `data` passed through `PackageSerializer` will be posted to https://example.com/. + +```python +import requests + +requests.post( + url='https://example.com/', + headers={ + 'Content-Type': 'application/json', + 'X-Whisperer-Event': 'package-created', + }, + json={ + 'event': { + 'type': 'package-created', + 'uuid': 'da81e85139824c6187dd1e58a7d3f971', + }, + 'data': { + 'id': 61, + 'transfer_id': 49, + 'order_number': '248398923123', + '.....': '......', + } + } +) +``` + +In order to cancel the subscription: + +```python +import requests + +requests.delete( + url='https://your-app.com/whisperer/hooks/<webhook-id>/', + headers={ + 'Authorization': 'Token <secret-login-token>', + } +) +``` + + + + +%prep +%autosetup -n dj-whisperer-0.2.13 + +%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-dj-whisperer -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Fri May 05 2023 Python_Bot <Python_Bot@openeuler.org> - 0.2.13-1 +- Package Spec generated @@ -0,0 +1 @@ +65f64cea8a8284f24d73e82375af024e dj-whisperer-0.2.13.tar.gz |