forked from platypush/platypush
Merge branch 'master' into 191-support-for-general-entities-backend-and-plugin
This commit is contained in:
commit
30dfdeecb0
3 changed files with 99 additions and 39 deletions
30
README.md
30
README.md
|
@ -6,6 +6,7 @@ Platypush
|
|||
[![pip version](https://img.shields.io/pypi/v/platypush.svg?style=flat)](https://pypi.python.org/pypi/platypush/)
|
||||
[![License](https://img.shields.io/github/license/BlackLight/platypush.svg)](https://git.platypush.tech/platypush/platypush/-/blob/master/LICENSE.txt)
|
||||
[![Last Commit](https://img.shields.io/github/last-commit/BlackLight/platypush.svg)](https://git.platypush.tech/platypush/platypush/-/commits/master/)
|
||||
[![Join chat on Matrix](https://img.shields.io/matrix/:platypush?server_fqdn=matrix.platypush.tech)](https://matrix.to/#/#platypush:matrix.platypush.tech)
|
||||
[![Contributions](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://git.platypush.tech/platypush/platypush/-/blob/master/CONTRIBUTING.md)
|
||||
[![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/BlackLight/platypush.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/BlackLight/platypush/context:python)
|
||||
[![Language grade: JavaScript](https://img.shields.io/lgtm/grade/javascript/g/BlackLight/platypush.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/BlackLight/platypush/context:javascript)
|
||||
|
@ -23,6 +24,9 @@ Platypush
|
|||
* [The web interface](#the-web-interface)
|
||||
- [Installation](#installation)
|
||||
* [System installation](#system-installation)
|
||||
+ [Install through `pip`](#install-through-pip)
|
||||
+ [Install through a system package manager](#install-through-a-system-package-manager)
|
||||
+ [Install from sources](#install-from-sources)
|
||||
* [Installing the dependencies for your extensions](#installing-the-dependencies-for-your-extensions)
|
||||
+ [Install via `extras` name](#install-via-extras-name)
|
||||
+ [Install via `manifest.yaml`](#install-via-manifestyaml)
|
||||
|
@ -440,15 +444,33 @@ Platypush uses Redis to deliver and store requests and temporary messages:
|
|||
[sudo] systemctl start redis
|
||||
```
|
||||
|
||||
To install the core platform:
|
||||
|
||||
- The `pip` way:
|
||||
#### Install through `pip`
|
||||
|
||||
```shell
|
||||
[sudo] pip3 install platypush
|
||||
```
|
||||
|
||||
- The sources way:
|
||||
#### Install through a system package manager
|
||||
|
||||
Note: currently only Arch Linux and derived distributions are supported.
|
||||
|
||||
You can either install the
|
||||
[`platypush`](https://aur.archlinux.org/packages/platypush) package (for the
|
||||
latest stable version) or the
|
||||
[`platypush-git`](https://aur.archlinux.org/packages/platypush-git) package
|
||||
(for the latest git version) through your favourite AUR package manager. For
|
||||
example, using `yay`:
|
||||
|
||||
```shell
|
||||
yay platypush
|
||||
# Or
|
||||
yay platypush-git
|
||||
```
|
||||
|
||||
The Arch Linux packages on AUR are automatically updated upon new git commits
|
||||
or tags.
|
||||
|
||||
#### Install from sources
|
||||
|
||||
```shell
|
||||
git clone https://git.platypush.tech/platypush/platypush.git
|
||||
|
|
|
@ -53,8 +53,15 @@ class Daemon:
|
|||
# number of executions retries before a request fails
|
||||
n_tries = 2
|
||||
|
||||
def __init__(self, config_file=None, pidfile=None, requests_to_process=None,
|
||||
no_capture_stdout=False, no_capture_stderr=False, redis_queue=None):
|
||||
def __init__(
|
||||
self,
|
||||
config_file=None,
|
||||
pidfile=None,
|
||||
requests_to_process=None,
|
||||
no_capture_stdout=False,
|
||||
no_capture_stderr=False,
|
||||
redis_queue=None,
|
||||
):
|
||||
"""
|
||||
Constructor
|
||||
Params:
|
||||
|
@ -82,8 +89,11 @@ class Daemon:
|
|||
logging.basicConfig(**Config.get('logging'))
|
||||
|
||||
redis_conf = Config.get('backend.redis') or {}
|
||||
self.bus = RedisBus(redis_queue=self.redis_queue, on_message=self.on_message(),
|
||||
**redis_conf.get('redis_args', {}))
|
||||
self.bus = RedisBus(
|
||||
redis_queue=self.redis_queue,
|
||||
on_message=self.on_message(),
|
||||
**redis_conf.get('redis_args', {})
|
||||
)
|
||||
|
||||
self.no_capture_stdout = no_capture_stdout
|
||||
self.no_capture_stderr = no_capture_stderr
|
||||
|
@ -101,33 +111,59 @@ class Daemon:
|
|||
args -- Your sys.argv[1:] [List of strings]
|
||||
"""
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--config', '-c', dest='config', required=False,
|
||||
default=None, help=cls.config_file.__doc__)
|
||||
parser.add_argument('--pidfile', '-P', dest='pidfile', required=False,
|
||||
default=None, help="File where platypush will " +
|
||||
"store its PID, useful if you're planning to " +
|
||||
"integrate it in a service")
|
||||
parser.add_argument('--no-capture-stdout', dest='no_capture_stdout',
|
||||
required=False, action='store_true',
|
||||
help="Set this flag if you have max stack depth " +
|
||||
"exceeded errors so stdout won't be captured by " +
|
||||
"the logging system")
|
||||
parser.add_argument('--no-capture-stderr', dest='no_capture_stderr',
|
||||
required=False, action='store_true',
|
||||
help="Set this flag if you have max stack depth " +
|
||||
"exceeded errors so stderr won't be captured by " +
|
||||
"the logging system")
|
||||
parser.add_argument('--redis-queue', dest='redis_queue',
|
||||
required=False, action='store_true',
|
||||
parser.add_argument(
|
||||
'--config',
|
||||
'-c',
|
||||
dest='config',
|
||||
required=False,
|
||||
default=None,
|
||||
help=cls.config_file.__doc__,
|
||||
)
|
||||
parser.add_argument(
|
||||
'--pidfile',
|
||||
'-P',
|
||||
dest='pidfile',
|
||||
required=False,
|
||||
default=None,
|
||||
help="File where platypush will "
|
||||
+ "store its PID, useful if you're planning to "
|
||||
+ "integrate it in a service",
|
||||
)
|
||||
parser.add_argument(
|
||||
'--no-capture-stdout',
|
||||
dest='no_capture_stdout',
|
||||
required=False,
|
||||
action='store_true',
|
||||
help="Set this flag if you have max stack depth "
|
||||
+ "exceeded errors so stdout won't be captured by "
|
||||
+ "the logging system",
|
||||
)
|
||||
parser.add_argument(
|
||||
'--no-capture-stderr',
|
||||
dest='no_capture_stderr',
|
||||
required=False,
|
||||
action='store_true',
|
||||
help="Set this flag if you have max stack depth "
|
||||
+ "exceeded errors so stderr won't be captured by "
|
||||
+ "the logging system",
|
||||
)
|
||||
parser.add_argument(
|
||||
'--redis-queue',
|
||||
dest='redis_queue',
|
||||
required=False,
|
||||
default=cls._default_redis_queue,
|
||||
help="Name of the Redis queue to be used to internally deliver messages "
|
||||
"(default: platypush/bus)")
|
||||
"(default: platypush/bus)",
|
||||
)
|
||||
|
||||
opts, args = parser.parse_known_args(args)
|
||||
return cls(config_file=opts.config, pidfile=opts.pidfile,
|
||||
return cls(
|
||||
config_file=opts.config,
|
||||
pidfile=opts.pidfile,
|
||||
no_capture_stdout=opts.no_capture_stdout,
|
||||
no_capture_stderr=opts.no_capture_stderr,
|
||||
redis_queue=opts.redis_queue)
|
||||
redis_queue=opts.redis_queue,
|
||||
)
|
||||
|
||||
def on_message(self):
|
||||
"""
|
||||
|
@ -148,8 +184,10 @@ class Daemon:
|
|||
logger.info('Dropped unauthorized request: {}'.format(msg))
|
||||
|
||||
self.processed_requests += 1
|
||||
if self.requests_to_process \
|
||||
and self.processed_requests >= self.requests_to_process:
|
||||
if (
|
||||
self.requests_to_process
|
||||
and self.processed_requests >= self.requests_to_process
|
||||
):
|
||||
self.stop_app()
|
||||
elif isinstance(msg, Response):
|
||||
logger.info('Received response: {}'.format(msg))
|
||||
|
|
|
@ -102,7 +102,7 @@ class RssPlugin(RunnablePlugin):
|
|||
{
|
||||
'feed_url': url,
|
||||
'feed_title': getattr(feed.feed, 'title', None),
|
||||
'id': entry.id,
|
||||
'id': getattr(entry, 'id', None),
|
||||
'url': entry.link,
|
||||
'published': datetime.datetime.fromtimestamp(time.mktime(entry.published_parsed)),
|
||||
'title': entry.title,
|
||||
|
|
Loading…
Reference in a new issue