![Mercury release](https://img.shields.io/badge/Current%20Mercury%20Version-Emailer-red?style=for-the-badge)
![mercury-py logo](https://github.com/CoffeePerry/mercury-py/blob/master/art/mercury.png?raw=true)
![GitHub release (latest by date)](https://img.shields.io/github/v/release/CoffeePerry/mercury-py)
![PyPI](https://img.shields.io/pypi/v/mercury-py?logo=PyPI&logoColor=white)
![PyPI - Status](https://img.shields.io/pypi/status/mercury-py)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/mercury-py?logo=Python&logoColor=white)
![PyPI - Implementation](https://img.shields.io/pypi/implementation/mercury-py)
[![Flask](https://img.shields.io/badge/framework-Flask-black?logo=Flask&logoColor=white)](https://github.com/pallets/flask/)
[![GitHub license](https://img.shields.io/github/license/CoffeePerry/mercury-py)](https://github.com/CoffeePerry/mercury-py/blob/master/LICENSE)
[![GitHub issues](https://img.shields.io/github/issues/CoffeePerry/mercury-py)](https://github.com/CoffeePerry/mercury-py/issues)
# mercury-py
**mercury-py** (*Mercury for Python*) is a Python based microservice that allow to manage scheduled notifications'
sending.
## Introduction
The project consists of a *Flask-based* **RESTful Web API**, through which it is possible to manage the scheduling
of notifications.
*SQLite* database is used internally.
*MongoDB* database is used to store scheduled notifications.
The dispatch of notifications is managed by *Celery-based* submodules:
- A **Celery Beat** that acts as an activator for the **Workers**.
- A **Celery Worker** for each category of notification, who takes care of managing the specific type of dispatch.
*RabbitMQ* message-broker is used for interprocess communications.
## Notifications Categories
The categories of notifications that can currently be sent are:
- Email.
Categories will be implemented:
- SMS;
- Push notification - *Firebase Cloud Messaging* (*FCM*);
- *Telegram* message.
## Setup instructions
### Getting it
To download mercury, either fork this *GitHub* repo or simply download it from *PyPI* via *pip*:
~~~
pip install mercury-py
~~~
### Install Dependencies
Mercury needs:
- *MongoDB*: get it from the official site (*https://www.mongodb.com/*) or from the official
repository of your Linux distro, for example, on *Debian-like* systems:
~~~
sudo apt install mongodb
~~~
- *RabbitMQ*: get it from the official site (*https://www.rabbitmq.com/*) or from the official
repository of your Linux distro, for example, on *Debian-like* systems:
~~~
sudo apt install rabbitmq-server
~~~
After that, to use Mercury, we need to create a *RabbitMQ* user, a virtual host and allow that user access to that virtual host:
From terminal, type (substitute in appropriate values for [MYUSER] and [MYPASSWORD] below):
~~~
sudo rabbitmqctl add_user [MYUSER] [MYPASSWORD]
sudo rabbitmqctl add_vhost mercury
sudo rabbitmqctl set_permissions -p mercury [MYUSER] ".*" ".*" ".*"
~~~
See the *RabbitMQ* *Admin Guide* for more information about access control
(*http://www.rabbitmq.com/admin-guide.html#access-control*).
### Setting up
Copy and paste file **config-\*.py**, from folder **configs**, into folder **mercury-instance**
and modify it according to your needs.
#### Configure the Secret Key
SECRET_KEY should be changed to some random bytes in production.
You can use the following command to output a random secret key:
~~~
$ python -c 'import os; print(os.urandom(16))'
~~~
Then place returned value into your **config.py**.
### Starting **Celery Worker** Alternative
[Source](https://docs.celeryq.dev/en/stable/userguide/periodic-tasks.html#starting-the-scheduler)
You can also embed beat inside the worker by enabling the workers -B option, this is convenient if you’ll never run more than one worker node, but it’s not commonly used and for that reason isn’t recommended for production use:
~~~
celery -A mercury.app.celery worker -B --logfile=instance\logs\celery.log --pidfile=instance\celerybeat\celery.pid --schedule=instance\celerybeat\celery-schedule.db --loglevel=DEBUG
~~~
### **Note**: *Windows* Systems
On *Windows* systems, an additional dependency must be installed in order for Celery-based submodules to function
properly.
Download and install *Gevent* from *PyPI* via *pip*:
~~~
pip install gevent
~~~
And run (**Celery Beat** and **Celery Workers**) from terminal:
~~~
celery -A mercury.app.celery worker --logfile=instance/logs/celeryworker.log --loglevel=DEBUG --pool=gevent
celery -A mercury.app.celery beat --logfile=instance/logs/celerybeat.log --loglevel=DEBUG --pidfile=instance/celerybeat/celerybeat.pid --schedule=instance/celerybeat/celerybeat-schedule.db
~~~
Raw data
{
"_id": null,
"home_page": "https://github.com/CoffeePerry/mercury-py",
"name": "mercury-py",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "notifications,authentication,email,sms,push notification,telegram",
"author": "Simone Perini",
"author_email": "perinisimone98@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/07/f9/ab31b8ad079632a1e4fa43ef387aab858928a3b8495557a12c0944871f8f/mercury-py-1.0.6.tar.gz",
"platform": null,
"description": "![Mercury release](https://img.shields.io/badge/Current%20Mercury%20Version-Emailer-red?style=for-the-badge)\n\n![mercury-py logo](https://github.com/CoffeePerry/mercury-py/blob/master/art/mercury.png?raw=true)\n\n![GitHub release (latest by date)](https://img.shields.io/github/v/release/CoffeePerry/mercury-py)\n![PyPI](https://img.shields.io/pypi/v/mercury-py?logo=PyPI&logoColor=white)\n![PyPI - Status](https://img.shields.io/pypi/status/mercury-py)\n\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/mercury-py?logo=Python&logoColor=white)\n![PyPI - Implementation](https://img.shields.io/pypi/implementation/mercury-py)\n\n[![Flask](https://img.shields.io/badge/framework-Flask-black?logo=Flask&logoColor=white)](https://github.com/pallets/flask/)\n\n[![GitHub license](https://img.shields.io/github/license/CoffeePerry/mercury-py)](https://github.com/CoffeePerry/mercury-py/blob/master/LICENSE)\n\n[![GitHub issues](https://img.shields.io/github/issues/CoffeePerry/mercury-py)](https://github.com/CoffeePerry/mercury-py/issues)\n\n# mercury-py\n**mercury-py** (*Mercury for Python*) is a Python based microservice that allow to manage scheduled notifications'\nsending.\n\n## Introduction\nThe project consists of a *Flask-based* **RESTful Web API**, through which it is possible to manage the scheduling\nof notifications.\n\n*SQLite* database is used internally.\n\n*MongoDB* database is used to store scheduled notifications.\n\nThe dispatch of notifications is managed by *Celery-based* submodules:\n- A **Celery Beat** that acts as an activator for the **Workers**.\n- A **Celery Worker** for each category of notification, who takes care of managing the specific type of dispatch.\n\n*RabbitMQ* message-broker is used for interprocess communications.\n\n## Notifications Categories\nThe categories of notifications that can currently be sent are:\n- Email.\n\nCategories will be implemented:\n- SMS;\n- Push notification - *Firebase Cloud Messaging* (*FCM*);\n- *Telegram* message.\n\n## Setup instructions\n\n### Getting it\nTo download mercury, either fork this *GitHub* repo or simply download it from *PyPI* via *pip*:\n~~~\npip install mercury-py\n~~~\n\n### Install Dependencies\nMercury needs:\n- *MongoDB*: get it from the official site (*https://www.mongodb.com/*) or from the official\nrepository of your Linux distro, for example, on *Debian-like* systems:\n~~~\nsudo apt install mongodb\n~~~\n- *RabbitMQ*: get it from the official site (*https://www.rabbitmq.com/*) or from the official\nrepository of your Linux distro, for example, on *Debian-like* systems:\n~~~\nsudo apt install rabbitmq-server\n~~~\n\nAfter that, to use Mercury, we need to create a *RabbitMQ* user, a virtual host and allow that user access to that virtual host:\n\nFrom terminal, type (substitute in appropriate values for [MYUSER] and [MYPASSWORD] below):\n\n~~~\nsudo rabbitmqctl add_user [MYUSER] [MYPASSWORD]\nsudo rabbitmqctl add_vhost mercury\nsudo rabbitmqctl set_permissions -p mercury [MYUSER] \".*\" \".*\" \".*\"\n~~~\nSee the *RabbitMQ* *Admin Guide* for more information about access control\n(*http://www.rabbitmq.com/admin-guide.html#access-control*).\n\n### Setting up\n\nCopy and paste file **config-\\*.py**, from folder **configs**, into folder **mercury-instance**\nand modify it according to your needs.\n\n#### Configure the Secret Key\nSECRET_KEY should be changed to some random bytes in production.\n\nYou can use the following command to output a random secret key:\n~~~\n$ python -c 'import os; print(os.urandom(16))'\n~~~\n\nThen place returned value into your **config.py**.\n\n### Starting **Celery Worker** Alternative\n\n[Source](https://docs.celeryq.dev/en/stable/userguide/periodic-tasks.html#starting-the-scheduler)\n\nYou can also embed beat inside the worker by enabling the workers -B option, this is convenient if you\u2019ll never run more than one worker node, but it\u2019s not commonly used and for that reason isn\u2019t recommended for production use:\n~~~\ncelery -A mercury.app.celery worker -B --logfile=instance\\logs\\celery.log --pidfile=instance\\celerybeat\\celery.pid --schedule=instance\\celerybeat\\celery-schedule.db --loglevel=DEBUG\n~~~\n\n### **Note**: *Windows* Systems\n\nOn *Windows* systems, an additional dependency must be installed in order for Celery-based submodules to function\nproperly.\n\nDownload and install *Gevent* from *PyPI* via *pip*:\n~~~\npip install gevent\n~~~\nAnd run (**Celery Beat** and **Celery Workers**) from terminal:\n~~~\ncelery -A mercury.app.celery worker --logfile=instance/logs/celeryworker.log --loglevel=DEBUG --pool=gevent\ncelery -A mercury.app.celery beat --logfile=instance/logs/celerybeat.log --loglevel=DEBUG --pidfile=instance/celerybeat/celerybeat.pid --schedule=instance/celerybeat/celerybeat-schedule.db\n~~~\n",
"bugtrack_url": null,
"license": "GPL-3.0",
"summary": "mercury-py (Mercury for Python) is a Python based microservice that allow to manage scheduled notifications sending.",
"version": "1.0.6",
"split_keywords": [
"notifications",
"authentication",
"email",
"sms",
"push notification",
"telegram"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "3e02c0e81afbc975d77a0dbb69641889b68c56eed8189a5a708e2f5917687c54",
"md5": "29fa4ac9ce15623826a4e8b2c185993e",
"sha256": "a5d94b2ababe12d2a9cc22ff971d8bdafbe8a16af8819c2b1fea99e596de8090"
},
"downloads": -1,
"filename": "mercury_py-1.0.6-py3-none-any.whl",
"has_sig": false,
"md5_digest": "29fa4ac9ce15623826a4e8b2c185993e",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 69472,
"upload_time": "2023-02-07T21:27:33",
"upload_time_iso_8601": "2023-02-07T21:27:33.015758Z",
"url": "https://files.pythonhosted.org/packages/3e/02/c0e81afbc975d77a0dbb69641889b68c56eed8189a5a708e2f5917687c54/mercury_py-1.0.6-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "07f9ab31b8ad079632a1e4fa43ef387aab858928a3b8495557a12c0944871f8f",
"md5": "be4db28b930fe192f3394f760c2d762c",
"sha256": "c7d6977f6e75e42defdae16902be0899524bc028dde7709e33b3517bfcbaf2e5"
},
"downloads": -1,
"filename": "mercury-py-1.0.6.tar.gz",
"has_sig": false,
"md5_digest": "be4db28b930fe192f3394f760c2d762c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 61569,
"upload_time": "2023-02-07T21:27:39",
"upload_time_iso_8601": "2023-02-07T21:27:39.259080Z",
"url": "https://files.pythonhosted.org/packages/07/f9/ab31b8ad079632a1e4fa43ef387aab858928a3b8495557a12c0944871f8f/mercury-py-1.0.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-02-07 21:27:39",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "CoffeePerry",
"github_project": "mercury-py",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "amqp",
"specs": [
[
"==",
"5.1.1"
]
]
},
{
"name": "aniso8601",
"specs": [
[
"==",
"9.0.1"
]
]
},
{
"name": "billiard",
"specs": [
[
"==",
"3.6.4.0"
]
]
},
{
"name": "blinker",
"specs": [
[
"==",
"1.5"
]
]
},
{
"name": "celery",
"specs": [
[
"==",
"5.2.7"
]
]
},
{
"name": "cffi",
"specs": [
[
"==",
"1.15.1"
]
]
},
{
"name": "click-didyoumean",
"specs": [
[
"==",
"0.3.0"
]
]
},
{
"name": "click-plugins",
"specs": [
[
"==",
"1.1.1"
]
]
},
{
"name": "click-repl",
"specs": [
[
"==",
"0.2.0"
]
]
},
{
"name": "click",
"specs": [
[
"==",
"8.1.3"
]
]
},
{
"name": "colorama",
"specs": [
[
"==",
"0.4.6"
]
]
},
{
"name": "dnspython",
"specs": [
[
"==",
"2.3.0"
]
]
},
{
"name": "flask-jwt-extended",
"specs": [
[
"==",
"4.4.4"
]
]
},
{
"name": "flask-mail",
"specs": [
[
"==",
"0.9.1"
]
]
},
{
"name": "flask-pymongo",
"specs": [
[
"==",
"2.3.0"
]
]
},
{
"name": "flask-restful",
"specs": [
[
"==",
"0.3.9"
]
]
},
{
"name": "flask-sqlalchemy",
"specs": [
[
"==",
"3.0.3"
]
]
},
{
"name": "flask",
"specs": [
[
"==",
"2.2.2"
]
]
},
{
"name": "gevent",
"specs": [
[
"==",
"22.10.2"
]
]
},
{
"name": "greenlet",
"specs": [
[
"==",
"2.0.2"
]
]
},
{
"name": "itsdangerous",
"specs": [
[
"==",
"2.1.2"
]
]
},
{
"name": "jinja2",
"specs": [
[
"==",
"3.1.2"
]
]
},
{
"name": "kombu",
"specs": [
[
"==",
"5.2.4"
]
]
},
{
"name": "markupsafe",
"specs": [
[
"==",
"2.1.2"
]
]
},
{
"name": "prompt-toolkit",
"specs": [
[
"==",
"3.0.36"
]
]
},
{
"name": "pycparser",
"specs": [
[
"==",
"2.21"
]
]
},
{
"name": "pyjwt",
"specs": [
[
"==",
"2.6.0"
]
]
},
{
"name": "pymongo",
"specs": [
[
"==",
"4.3.3"
]
]
},
{
"name": "pytz",
"specs": [
[
"==",
"2022.7.1"
]
]
},
{
"name": "setuptools",
"specs": [
[
"==",
"67.2.0"
]
]
},
{
"name": "six",
"specs": [
[
"==",
"1.16.0"
]
]
},
{
"name": "sqlalchemy",
"specs": [
[
"==",
"2.0.2"
]
]
},
{
"name": "typing-extensions",
"specs": [
[
"==",
"4.4.0"
]
]
},
{
"name": "vine",
"specs": [
[
"==",
"5.0.0"
]
]
},
{
"name": "wcwidth",
"specs": [
[
"==",
"0.2.6"
]
]
},
{
"name": "werkzeug",
"specs": [
[
"==",
"2.2.2"
]
]
},
{
"name": "zope.event",
"specs": [
[
"==",
"4.6"
]
]
},
{
"name": "zope.interface",
"specs": [
[
"==",
"5.5.2"
]
]
}
],
"lcname": "mercury-py"
}