Merge pull request '[#316] RPM support' (#328) from 316/rpm-support into master
continuous-integration/drone/push Build is failing Details

Reviewed-on: #328
This commit is contained in:
Fabio Manganiello 2023-09-23 16:25:34 +02:00
commit fe5158d0ca
83 changed files with 535 additions and 168 deletions

View File

@ -273,10 +273,9 @@ steps:
environment: environment:
DEB_VERSION: stable DEB_VERSION: stable
WORKDIR: /tmp/workdir WORKDIR: /tmp/workdir
STABLE_PKG_NAME: platypush
PKG_NAME: platypush PKG_NAME: platypush
S3_URL: s3://platypush-pkg/apt S3_URL: s3://platypush-pkg/apt
AWS_ENDPOINT_URL: https://s3.nl-ams.scw.cloud AWS_ENDPOINT_URL: https://s3.nl-ams.scw.cloud
AWS_DEFAULT_REGION: nl-ams AWS_DEFAULT_REGION: nl-ams
AWS_ACCESS_KEY_ID: AWS_ACCESS_KEY_ID:
from_secret: aws_access_key_id from_secret: aws_access_key_id
@ -368,10 +367,9 @@ steps:
environment: environment:
DEB_VERSION: oldstable DEB_VERSION: oldstable
WORKDIR: /tmp/workdir WORKDIR: /tmp/workdir
STABLE_PKG_NAME: platypush
PKG_NAME: platypush PKG_NAME: platypush
S3_URL: s3://platypush-pkg/apt S3_URL: s3://platypush-pkg/apt
AWS_ENDPOINT_URL: https://s3.nl-ams.scw.cloud AWS_ENDPOINT_URL: https://s3.nl-ams.scw.cloud
AWS_DEFAULT_REGION: nl-ams AWS_DEFAULT_REGION: nl-ams
AWS_ACCESS_KEY_ID: AWS_ACCESS_KEY_ID:
from_secret: aws_access_key_id from_secret: aws_access_key_id
@ -464,7 +462,7 @@ steps:
environment: environment:
S3_BUCKET: platypush-pkg S3_BUCKET: platypush-pkg
BUCKET_MNT: /mnt/s3 BUCKET_MNT: /mnt/s3
AWS_ENDPOINT_URL: https://s3.nl-ams.scw.cloud AWS_ENDPOINT_URL: https://s3.nl-ams.scw.cloud
AWS_DEFAULT_REGION: nl-ams AWS_DEFAULT_REGION: nl-ams
AWS_ACCESS_KEY_ID: AWS_ACCESS_KEY_ID:
from_secret: aws_access_key_id from_secret: aws_access_key_id
@ -576,6 +574,202 @@ steps:
cat "$file" | gpg -q --default-key "$PGP_KEYID" -abs --clearsign > "$dirname/InRelease" cat "$file" | gpg -q --default-key "$PGP_KEYID" -abs --clearsign > "$dirname/InRelease"
done done
###
### Update the RPM (stable) packages
###
- name: update-rpm-repo
image: fedora
privileged: true # Required to use the FUSE module for s3fs
environment:
RPM_VERSION: stable
WORKDIR: /tmp/workdir
PKG_NAME: platypush
S3_BUCKET: platypush-pkg
BUCKET_MNT: /mnt/s3
AWS_ENDPOINT_URL: https://s3.nl-ams.scw.cloud
AWS_DEFAULT_REGION: nl-ams
AWS_ACCESS_KEY_ID:
from_secret: aws_access_key_id
AWS_SECRET_ACCESS_KEY:
from_secret: aws_secret_access_key
PGP_PUBKEY:
from_secret: rpm_pgp_pub_key
PGP_PRIVKEY:
from_secret: rpm_pgp_priv_key
when:
branch:
- master
event:
- push
depends_on:
- build-ui
commands:
- echo "-- Installing dependencies"
- yum install -y createrepo rpm-build rpm-sign gpg wget yum-utils git python python-pip s3fs-fuse
- echo "-- Copying source directory"
- mkdir -p "$WORKDIR"
- export SRCDIR="$WORKDIR/src"
- cp -r "$PWD" "$SRCDIR"
- cd "$SRCDIR"
- echo "-- Mounting the S3 bucket"
- mkdir -p "$BUCKET_MNT"
- s3fs "$S3_BUCKET" "$BUCKET_MNT" -o url="$AWS_ENDPOINT_URL"
- export RPM_ROOT="$BUCKET_MNT/rpm"
- mkdir -p "$RPM_ROOT"
- echo "--- Parsing metadata"
- git config --global --add safe.directory $PWD
- git pull --rebase origin master --tags
- export VERSION=$(python3 setup.py --version)
- export RELNUM=$(git log --pretty=oneline HEAD...v$VERSION | wc -l)
- export SPECFILE="$WORKDIR/$PKG_NAME.spec"
- export BUILD_DIR="$WORKDIR/build"
- export TMP_RPM_ROOT="$WORKDIR/repo"
- export SRC_URL="https://git.platypush.tech/platypush/platypush/archive/master.tar.gz"
- echo "--- Creating git package spec"
- |
cat <<EOF > $SPECFILE
Summary: Universal command executor and automation hub.
Name: $PKG_NAME-git
Version: $VERSION
Release: $RELNUM
URL: https://platypush.tech
Group: System
License: MIT
Packager: Fabio Manganiello <fabio@platypush.tech>
Source: $SRC_URL
Requires: $(cat platypush/install/requirements/fedora.txt | tr '\n' ' ')
Conflicts: $PKG_NAME
Prefix: %{_prefix}
BuildRoot: %{_tmppath}/%{name}-root
%description
Universal command executor and automation hub.
%install
mkdir -p %{buildroot}/
cp -r "$BUILD_DIR"/* %{buildroot}/
%clean
%files
/usr/bin/*
/usr/lib/python$(python3 --version | awk '{print $2}' | cut -d. -f 1,2)/site-packages/platypush
/usr/lib/python$(python3 --version | awk '{print $2}' | cut -d. -f 1,2)/site-packages/platypush-$VERSION.dist-info
%changelog
* $(date +'%a %b %d %Y') admin <admin@platypush.tech>
- [Automatic] Release $VERSION-$RELNUM
EOF
- echo "--- Building git package"
- mkdir -p "$BUILD_DIR"
- pip install --prefix="$BUILD_DIR/usr" --no-cache --no-deps .
- rpmbuild --target "noarch" -bb "$SPECFILE"
- echo "--- Copying the new RPM package"
- mkdir -p "$TMP_RPM_ROOT"
- cp "$HOME/rpmbuild/RPMS/noarch/$PKG_NAME-git-$VERSION-$RELNUM.noarch.rpm" "$TMP_RPM_ROOT"
- echo "--- Checking the latest released stable version"
- export LATEST_STABLE_PKG=$(ls -rt "$RPM_ROOT/$PKG_NAME"*.rpm 2>/dev/null | grep -v "$PKG_NAME-git" | tail -1)
- |
if [ -z "$LATEST_STABLE_PKG" ]; then
# If not stable release is available, then create one
export UPDATE_STABLE_PKG=1
else
# Otherwise, create a new release if the reported version on the repo is different
# from the latest released version.
export LATEST_STABLE_VERSION=$(basename $LATEST_STABLE_PKG | cut -d- -f 2)
if [ "$VERSION" != "$LATEST_STABLE_VERSION" ]; then
export UPDATE_STABLE_PKG=1
else
# If the version has remained the same, then simply copy the existing RPM to the
# new repository directory.
echo "Copying the existing release $LATEST_STABLE_VERSION to the new repository"
cp "$LATEST_STABLE_PKG" "$TMP_RPM_ROOT"
fi
fi
# If a new stable release is required, build another RPM
- |
if [ -n "$UPDATE_STABLE_PKG" ]; then
export RELNUM=1
export SRC_URL="https://git.platypush.tech/platypush/platypush/archive/v$VERSION.tar.gz"
cat <<EOF > $SPECFILE
Summary: Universal command executor and automation hub.
Name: $PKG_NAME
Version: $VERSION
Release: $RELNUM
URL: https://platypush.tech
Group: System
License: MIT
Packager: Fabio Manganiello <fabio@platypush.tech>
Source: $SRC_URL
Requires: $(cat platypush/install/requirements/fedora.txt | tr '\n' ' ')
Conflicts: $PKG_NAME-git
Prefix: %{_prefix}
BuildRoot: %{_tmppath}/%{name}-root
%description
Universal command executor and automation hub.
%install
mkdir -p %{buildroot}/
cp -r "$BUILD_DIR"/* %{buildroot}/
%clean
%files
/usr/bin/*
/usr/lib/python$(python3 --version | awk '{print $2}' | cut -d. -f 1,2)/site-packages/platypush
/usr/lib/python$(python3 --version | awk '{print $2}' | cut -d. -f 1,2)/site-packages/platypush-$VERSION.dist-info
%changelog
* $(date +'%a %b %d %Y') admin <admin@platypush.tech>
- [Automatic] Release $VERSION-$RELNUM
EOF
echo "--- Building package for stable release $VERSION"
rpmbuild --target "noarch" -bb "$SPECFILE"
cp "$HOME/rpmbuild/RPMS/noarch/$PKG_NAME-$VERSION-$RELNUM.noarch.rpm" "$TMP_RPM_ROOT"
fi
- echo "--- Importing the repository keys"
- |
cat <<EOF | gpg --import --armor
$PGP_PRIVKEY
EOF
- export PGP_KEYID=$(echo "$PGP_PUBKEY" | gpg --with-colons --import-options show-only --import --fingerprint | grep -e '^fpr:' | head -1 | awk -F ':' '{print $(NF - 1)}')
- cat <<EOF > $HOME/.rpmmacros
%signature gpg
%_gpg_name $PGP_KEYID
EOF
- echo "--- Signing the new RPM packages"
- rpm --addsign "$TMP_RPM_ROOT"/*.rpm
- echo "--- Creating a new copy of the RPM repository"
- createrepo "$TMP_RPM_ROOT"
- gpg --detach-sign --armor "$TMP_RPM_ROOT/repodata/repomd.xml"
- echo "--- Updating the S3 bucket"
- export NEW_RPM_ROOT="$BUCKET_MNT/rpm_new"
- export OLD_RPM_ROOT="$BUCKET_MNT/rpm_old"
- mv "$TMP_RPM_ROOT" "$NEW_RPM_ROOT"
- mv "$RPM_ROOT" "$OLD_TMP_ROOT"
- mv "$NEW_RPM_ROOT" "$RPM_ROOT"
- rm -rf "$OLD_TMP_ROOT"
### ###
### Updates the pip package upon new releases ### Updates the pip package upon new releases
### ###
@ -614,10 +808,10 @@ steps:
- master - master
event: event:
- push - push
- tag
depends_on: depends_on:
- update-arch-packages - update-arch-packages
- update-rpm-repo
- update-apt-repo - update-apt-repo
commands: commands:
@ -639,7 +833,6 @@ steps:
depends_on: depends_on:
- update-pip-package - update-pip-package
- wait-pkg-update
commands: commands:
- apk add --update --no-cache curl - apk add --update --no-cache curl

View File

@ -16,7 +16,6 @@ Events
platypush/events/chat.slack.rst platypush/events/chat.slack.rst
platypush/events/chat.telegram.rst platypush/events/chat.telegram.rst
platypush/events/clipboard.rst platypush/events/clipboard.rst
platypush/events/covid19.rst
platypush/events/custom.rst platypush/events/custom.rst
platypush/events/dbus.rst platypush/events/dbus.rst
platypush/events/distance.rst platypush/events/distance.rst

View File

@ -1,5 +0,0 @@
``covid19``
===================================
.. automodule:: platypush.message.event.covid19
:members:

View File

@ -1,5 +0,0 @@
``covid19``
=============================
.. automodule:: platypush.plugins.covid19
:members:

View File

@ -27,7 +27,6 @@ Plugins
platypush/plugins/chat.telegram.rst platypush/plugins/chat.telegram.rst
platypush/plugins/clipboard.rst platypush/plugins/clipboard.rst
platypush/plugins/config.rst platypush/plugins/config.rst
platypush/plugins/covid19.rst
platypush/plugins/csv.rst platypush/plugins/csv.rst
platypush/plugins/db.rst platypush/plugins/db.rst
platypush/plugins/dbus.rst platypush/plugins/dbus.rst

View File

@ -25,6 +25,9 @@ manifest:
apt: apt:
- python3-grpcio - python3-grpcio
- python3-google-auth - python3-google-auth
dnf:
- python-grpcio
- python-google-auth
pacman: pacman:
- python-grpcio - python-grpcio
- python-google-auth - python-google-auth

View File

@ -4,6 +4,9 @@ manifest:
apk: apk:
- py3-numpy - py3-numpy
- py3-pillow - py3-pillow
dnf:
- python-numpy
- python-pillow
pacman: pacman:
- python-numpy - python-numpy
- python-pillow - python-pillow

View File

@ -8,6 +8,8 @@ manifest:
- py3-watchdog - py3-watchdog
apt: apt:
- python3-watchdog - python3-watchdog
dnf:
- python-watchdog
pacman: pacman:
- python-watchdog - python-watchdog
pip: pip:

View File

@ -10,6 +10,8 @@ manifest:
- gpsd - gpsd
apt: apt:
- gpsd - gpsd
dnf:
- gpsd
pacman: pacman:
- gpsd - gpsd
pip: pip:

View File

@ -13,6 +13,8 @@ manifest:
- py3-inotify - py3-inotify
apt: apt:
- python3-inotify - python3-inotify
dnf:
- python-inotify
pip: pip:
- inotify - inotify
package: platypush.backend.inotify package: platypush.backend.inotify

View File

@ -17,6 +17,8 @@ manifest:
- linuxconsoletools - linuxconsoletools
apt: apt:
- joystick - joystick
dnf:
- joystick
pacman: pacman:
- joyutils - joyutils
package: platypush.backend.joystick.jstest package: platypush.backend.joystick.jstest

View File

@ -3,6 +3,8 @@ manifest:
install: install:
apt: apt:
- python3-kafka - python3-kafka
dnf:
- python-kafka
pip: pip:
- kafka - kafka
package: platypush.backend.kafka package: platypush.backend.kafka

View File

@ -6,6 +6,8 @@ manifest:
- py3-watchdog - py3-watchdog
apt: apt:
- python3-watchdog - python3-watchdog
dnf:
- python-watchdog
pacman: pacman:
- python-watchdog - python-watchdog
pip: pip:

View File

@ -4,6 +4,8 @@ manifest:
install: install:
apt: apt:
- python3-rtmidi - python3-rtmidi
dnf:
- python-rtmidi
pacman: pacman:
- rtmidi - rtmidi
- python-rtmidi - python-rtmidi

View File

@ -5,6 +5,8 @@ manifest:
install: install:
apk: apk:
- py3-paho-mqtt - py3-paho-mqtt
dnf:
- python-paho-mqtt
pacman: pacman:
- python-paho-mqtt - python-paho-mqtt
apt: apt:

View File

@ -12,6 +12,8 @@ manifest:
install: install:
apt: apt:
- python3-mpd2 - python3-mpd2
dnf:
- python-mpd2
pacman: pacman:
- python-mpd2 - python-mpd2
pip: pip:

View File

@ -15,6 +15,9 @@ manifest:
apt: apt:
- sudo - sudo
- cargo - cargo
dnf:
- sudo
- cargo
pacman: pacman:
- sudo - sudo
- cargo - cargo

View File

@ -5,6 +5,8 @@ manifest:
- git - git
apt: apt:
- git - git
dnf:
- git
pacman: pacman:
- git - git
install: install:

View File

@ -5,10 +5,12 @@ manifest:
install: install:
apk: apk:
- py3-pyscard - py3-pyscard
pacman:
- python-pyscard
apt: apt:
- python3-pyscard - python3-pyscard
dnf:
- python-pyscard
pacman:
- python-pyscard
pip: pip:
- pyscard - pyscard
package: platypush.backend.scard package: platypush.backend.scard

View File

@ -3,6 +3,11 @@ manifest:
platypush.message.event.wiimote.WiimoteEvent: when the state of the Wiimote (battery, platypush.message.event.wiimote.WiimoteEvent: when the state of the Wiimote (battery,
buttons, acceleration etc.) changes buttons, acceleration etc.) changes
install: install:
pip: [] apt:
- libcwiid1
pacman:
- cwiid-git
pip:
- cwiid
package: platypush.backend.wiimote package: platypush.backend.wiimote
type: backend type: backend

View File

@ -16,6 +16,8 @@ manifest:
install: install:
apk: apk:
- py3-paho-mqtt - py3-paho-mqtt
dnf:
- python-paho-mqtt
pacman: pacman:
- python-paho-mqtt - python-paho-mqtt
apt: apt:

View File

@ -0,0 +1,26 @@
FROM fedora
ADD . /install
WORKDIR /var/lib/platypush
ARG DOCKER_CTX=1
ENV DOCKER_CTX=1
# Enable the RPM Fusion repository
RUN dnf install -y \
https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm
RUN /install/platypush/install/scripts/fedora/install.sh
RUN cd /install && pip install -U --no-input --no-cache-dir .
RUN rm -rf /install
RUN dnf clean all -y
EXPOSE 8008
VOLUME /etc/platypush
VOLUME /var/lib/platypush
CMD platypush \
--start-redis \
--config /etc/platypush/config.yaml \
--workdir /var/lib/platypush

View File

@ -0,0 +1,27 @@
python
python-pip
python-alembic
python-bcrypt
python-croniter
python-dateutil
python-docutils
python-flask
python-frozendict
python-greenlet
python-magic
python-marshmallow
python-mypy_extensions
python-psutil
python-pytz
python-redis
python-requests
python-rsa
python-sqlalchemy
python-tornado
python-websocket-client
python-websockets
python-wheel
python-yaml
python-zeroconf
redis
sudo

View File

@ -0,0 +1 @@
dnf install -y

View File

@ -0,0 +1,28 @@
#!/bin/sh
# This script parses the system requirements for a specific OS and it runs the
# appropriate package manager command to install them.
# This script is usually symlinked in the folders of the individual operating
# systems, and it's not supposed to be invoked directly.
# Instead, it will be called either by the root install.sh script or by a
# Dockerfile.
SCRIPT_PATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
OS="$(basename "$SCRIPT_PATH")"
CMD="$(cat "${SCRIPT_PATH}/PKGCMD")"
REQUIREMENTS="$(cat "${SCRIPT_PATH}/../../requirements/${OS}.txt" | tr '\n' ' ')"
SUDO=
# If we aren't running in a Docker context, or the user is not root, we should
# use sudo to install system packages.
if [ $(id -u) -ne 0 ] || [ -z "$DOCKER_CTX" ]; then
if ! type sudo >/dev/null; then
echo "sudo executable not found, I can't install system packages" >&2
exit 1
fi
SUDO="sudo"
fi
${SUDO_ARGS} ${CMD} ${REQUIREMENTS}

View File

@ -1,26 +0,0 @@
from datetime import datetime
from typing import Optional
from platypush.message.event import Event
class Covid19UpdateEvent(Event):
def __init__(self,
confirmed: int,
deaths: int,
recovered: int,
country: Optional[str] = None,
country_code: Optional[str] = None,
update_time: Optional[datetime] = None,
*args, **kwargs):
super().__init__(*args,
confirmed=confirmed,
deaths=deaths,
recovered=recovered,
country=country,
country_code=country_code,
update_time=update_time,
**kwargs)
# vim:sw=4:ts=4:et:

View File

@ -35,6 +35,7 @@ class DockerBuilder(BaseBuilder):
_pkg_manager_by_base_image = { _pkg_manager_by_base_image = {
BaseImage.ALPINE: PackageManagers.APK, BaseImage.ALPINE: PackageManagers.APK,
BaseImage.DEBIAN: PackageManagers.APT, BaseImage.DEBIAN: PackageManagers.APT,
BaseImage.FEDORA: PackageManagers.DNF,
BaseImage.UBUNTU: PackageManagers.APT, BaseImage.UBUNTU: PackageManagers.APT,
} }

View File

@ -13,6 +13,9 @@ manifest:
apt: apt:
- python3-tenacity - python3-tenacity
- python3-google-auth - python3-google-auth
dnf:
- python-tenacity
- python-google-auth
pacman: pacman:
- python-tenacity - python-tenacity
- python-google-auth - python-google-auth

View File

@ -20,6 +20,9 @@ manifest:
- libbluetooth-dev - libbluetooth-dev
- python3-pydbus - python3-pydbus
- git - git
dnf:
- python-pydbus
- git
pacman: pacman:
- python-pydbus - python-pydbus
- python-bleak - python-bleak

View File

@ -5,6 +5,8 @@ manifest:
- py3-icalendar - py3-icalendar
apt: apt:
- python3-icalendar - python3-icalendar
dnf:
- python-icalendar
pacman: pacman:
- python-icalendar - python-icalendar
pip: pip:

View File

@ -5,14 +5,18 @@ manifest:
- py3-numpy - py3-numpy
- py3-pillow - py3-pillow
- py3-opencv - py3-opencv
pacman:
- python-numpy
- python-pillow
- python-opencv
apt: apt:
- python3-numpy - python3-numpy
- python3-pillow - python3-pillow
- python3-opencv - python3-opencv
dnf:
- python-numpy
- python-pillow
- python-opencv
pacman:
- python-numpy
- python-pillow
- python-opencv
pip: pip:
- numpy - numpy
- opencv-python - opencv-python

View File

@ -5,14 +5,18 @@ manifest:
- py3-numpy - py3-numpy
- py3-pillow - py3-pillow
- ffmpeg - ffmpeg
pacman:
- python-numpy
- python-pillow
- ffmpeg
apt: apt:
- python3-numpy - python3-numpy
- python3-pillow - python3-pillow
- ffmpeg - ffmpeg
dnf:
- python-numpy
- python-pillow
- ffmpeg
pacman:
- python-numpy
- python-pillow
- ffmpeg
pip: pip:
- numpy - numpy
- Pillow - Pillow

View File

@ -6,16 +6,21 @@ manifest:
- py3-pillow - py3-pillow
- py3-gobject3 - py3-gobject3
- py3-gst - py3-gst
pacman:
- python-numpy
- python-pillow
- gst-python
- python-gobject
apt: apt:
- python3-numpy - python3-numpy
- python3-pillow - python3-pillow
- python3-gi - python3-gi
- python3-gst-1.0 - python3-gst-1.0
dnf:
- python-numpy
- python-pillow
- python-gstreamer1
- python-gobject
pacman:
- python-numpy
- python-pillow
- gst-python
- python-gobject
pip: pip:
- numpy - numpy
- Pillow - Pillow

View File

@ -5,14 +5,18 @@ manifest:
- i2c-tools-dev - i2c-tools-dev
- py3-numpy - py3-numpy
- py3-pillow - py3-pillow
pacman:
- i2c-tools
- python-numpy
- python-pillow
apt: apt:
- libi2c-dev - libi2c-dev
- python3-numpy - python3-numpy
- python3-pillow - python3-pillow
dnf:
- i2c-tools
- python-numpy
- python-pillow
pacman:
- i2c-tools
- python-numpy
- python-pillow
pip: pip:
- numpy - numpy
- Pillow - Pillow

View File

@ -4,12 +4,15 @@ manifest:
apk: apk:
- py3-numpy - py3-numpy
- py3-pillow - py3-pillow
pacman:
- python-numpy
- python-pillow
apt: apt:
- python3-numpy - python3-numpy
- python3-pillow - python3-pillow
dnf:
- python-numpy
- python-pillow
pacman:
- python-numpy
- python-pillow
pip: pip:
- picamera - picamera
- numpy - numpy

View File

@ -23,6 +23,8 @@ manifest:
install: install:
apt: apt:
- python3-irc - python3-irc
dnf:
- python-irc
pacman: pacman:
- python-irc - python-irc
pip: pip:

View File

@ -4,6 +4,10 @@ manifest:
install: install:
apk: apk:
- py3-pyclip - py3-pyclip
dnf:
- python-pyclip
pacman:
- python-pyclip
pip: pip:
- pyclip - pyclip
package: platypush.plugins.clipboard package: platypush.plugins.clipboard

View File

@ -1,72 +0,0 @@
from typing import Optional, Union, List, Dict, Any
import requests
from platypush.plugins import Plugin, action
class Covid19Plugin(Plugin):
"""
Monitor the diffusion data of the COVID-19 pandemic by using the public API at https://api.covid19api.com.
"""
base_url = 'https://api.covid19api.com'
def __init__(self, country: Union[str, List[str]] = 'world', **kwargs):
"""
:param country: Default country (or list of countries) to retrieve the stats for. It can either be the full
country name or the country code. Special values:
- ``world``: Get worldwide stats (default).
- ``all``: Get all the available stats.
"""
super().__init__(**kwargs)
self.country = []
self.all_countries = requests.get('{}/countries'.format(self.base_url)).json()
self.country = self._get_countries(country)
def _get_countries(self, country: Optional[Union[str, List[str]]] = None) -> List[str]:
country = country or self.country
if isinstance(country, str):
country = country.split(',')
lc_country = {c.lower() for c in country}
return [c['ISO2'] for c in self.all_countries
if c['ISO2'].lower() in lc_country
or c['Slug'].lower() in lc_country
or c['Country'].lower() in lc_country]
@action
def summary(self, country: Optional[Union[str, List[str]]] = None) -> List[Dict[str, Any]]:
"""
Get the summary data for the world or a country.
:param country: Default country override.
"""
countries = self._get_countries(country)
response = requests.get('{}/summary'.format(self.base_url)).json()
if countries[0] == 'all':
return response.get('Countries', [])
if countries[0] == 'world':
return response.get('Global', {})
return [
c for c in response.get('Countries', [])
if c.get('CountryCode').upper() in countries
or c.get('Country').upper() in countries
]
@action
def data(self, country: Optional[Union[str, List[str]]] = None) -> List[Dict[str, Any]]:
"""
Get all the data for a country.
:param country: Default country override.
"""
countries = self._get_countries(country)
ret = []
for country in countries:
ret += requests.get('{}/total/country/{}'.format(self.base_url, country)).json()
return ret
# vim:sw=4:ts=4:et:

View File

@ -1,6 +0,0 @@
manifest:
events: {}
install:
pip: []
package: platypush.plugins.covid19
type: plugin

View File

@ -8,6 +8,9 @@ manifest:
apt: apt:
- python3-pydbus - python3-pydbus
- python3-defusedxml - python3-defusedxml
dnf:
- python-pydbus
- python-defusedxml
pacman: pacman:
- python-pydbus - python-pydbus
- python-defusedxml - python-defusedxml

View File

@ -3,6 +3,8 @@ manifest:
install: install:
apt: apt:
- python3-dropbox - python3-dropbox
dnf:
- python-dropbox
pacman: pacman:
- python-dropbox - python-dropbox
pip: pip:

View File

@ -5,6 +5,8 @@ manifest:
- ffmpeg - ffmpeg
apt: apt:
- ffmpeg - ffmpeg
dnf:
- ffmpeg
pacman: pacman:
- ffmpeg - ffmpeg
- python-ffmpeg - python-ffmpeg

View File

@ -8,6 +8,10 @@ manifest:
apt: apt:
- python3-google-auth - python3-google-auth
- python3-oauth2client - python3-oauth2client
dnf:
- python-google-api-client
- python-google-auth
- python-oauth2client
pacman: pacman:
- python-google-api-python-client - python-google-api-python-client
- python-google-auth - python-google-auth

View File

@ -8,6 +8,10 @@ manifest:
apt: apt:
- python3-google-auth - python3-google-auth
- python3-oauth2client - python3-oauth2client
dnf:
- python-google-api-client
- python-google-auth
- python-oauth2client
pacman: pacman:
- python-google-api-python-client - python-google-api-python-client
- python-google-auth - python-google-auth

View File

@ -8,6 +8,10 @@ manifest:
apt: apt:
- python3-google-auth - python3-google-auth
- python3-oauth2client - python3-oauth2client
dnf:
- python-google-api-client
- python-google-auth
- python-oauth2client
pacman: pacman:
- python-google-api-python-client - python-google-api-python-client
- python-google-auth - python-google-auth

View File

@ -8,6 +8,10 @@ manifest:
apt: apt:
- python3-google-auth - python3-google-auth
- python3-oauth2client - python3-oauth2client
dnf:
- python-google-api-client
- python-google-auth
- python-oauth2client
pacman: pacman:
- python-google-api-python-client - python-google-api-python-client
- python-google-auth - python-google-auth

View File

@ -8,6 +8,10 @@ manifest:
apt: apt:
- python3-google-auth - python3-google-auth
- python3-oauth2client - python3-oauth2client
dnf:
- python-google-api-client
- python-google-auth
- python-oauth2client
pacman: pacman:
- python-google-api-python-client - python-google-api-python-client
- python-google-auth - python-google-auth

View File

@ -8,6 +8,10 @@ manifest:
apt: apt:
- python3-google-auth - python3-google-auth
- python3-oauth2client - python3-oauth2client
dnf:
- python-google-api-client
- python-google-auth
- python-oauth2client
pacman: pacman:
- python-google-api-python-client - python-google-api-python-client
- python-google-auth - python-google-auth

View File

@ -8,6 +8,10 @@ manifest:
apt: apt:
- python3-google-auth - python3-google-auth
- python3-oauth2client - python3-oauth2client
dnf:
- python-google-api-client
- python-google-auth
- python-oauth2client
pacman: pacman:
- python-google-api-python-client - python-google-api-python-client
- python-google-auth - python-google-auth

View File

@ -8,6 +8,10 @@ manifest:
apt: apt:
- python3-google-auth - python3-google-auth
- python3-oauth2client - python3-oauth2client
dnf:
- python-google-api-client
- python-google-auth
- python-oauth2client
pacman: pacman:
- python-google-api-python-client - python-google-api-python-client
- python-google-auth - python-google-auth

View File

@ -4,8 +4,12 @@ manifest:
platypush.message.event.hid.HidDeviceDisconnectedEvent: when a previously available device is disconnected platypush.message.event.hid.HidDeviceDisconnectedEvent: when a previously available device is disconnected
platypush.message.event.hid.HidDeviceDataEvent: when a monitored device sends some data platypush.message.event.hid.HidDeviceDataEvent: when a monitored device sends some data
install: install:
apk:
- python3-hidapi
apt: apt:
- python3-hid - python3-hid
dnf:
- python-hidapi
pacman: pacman:
- python-hid - python-hid
pip: pip:

View File

@ -1,7 +1,15 @@
manifest: manifest:
events: {} events: {}
install: install:
apk:
- py3-feedparser
apt:
- python3-feedparser
dnf:
- python-feedparser
pacman:
- python-feedparser
pip: pip:
- feedparser - feedparser
package: platypush.plugins.http.request.rss package: platypush.plugins.http.request.rss
type: plugin type: plugin

View File

@ -9,6 +9,10 @@ manifest:
- sudo - sudo
- nodejs - nodejs
- npm - npm
dnf:
- sudo
- nodejs
- npm
pacman: pacman:
- sudo - sudo
- nodejs - nodejs

View File

@ -1,4 +1,4 @@
#!node #!/usr/bin/node
// This script will parse the content and title of a webpage using the // This script will parse the content and title of a webpage using the
// mercury-parser JavaScript library (https://github.com/postlight/mercury-parser) // mercury-parser JavaScript library (https://github.com/postlight/mercury-parser)

View File

@ -3,7 +3,11 @@ manifest:
platypush.message.event.kafka.KafkaMessageEvent: when a new message is received platypush.message.event.kafka.KafkaMessageEvent: when a new message is received
on the consumer topic. on the consumer topic.
install: install:
apt:
- python-kafka
dnf:
- python-kafka
pip: pip:
- kafka - kafka
package: platypush.plugins.kafka package: platypush.plugins.kafka
type: plugin type: plugin

View File

@ -5,6 +5,8 @@ manifest:
- py3-pylast - py3-pylast
apt: apt:
- python3-pylast - python3-pylast
dnf:
- python-pylast
pacman: pacman:
- python-pylast - python-pylast
pip: pip:

View File

@ -43,6 +43,10 @@ manifest:
- olm-dev - olm-dev
apt: apt:
- libolm-devel - libolm-devel
- python3-async-lru
dnf:
- libolm-devel
- python-async-lru
pacman: pacman:
- libolm - libolm
- python-async-lru - python-async-lru

View File

@ -5,6 +5,8 @@ manifest:
- py3-pychromecast - py3-pychromecast
apt: apt:
- python3-pychromecast - python3-pychromecast
dnf:
- python-chromecast
pip: pip:
- pychromecast - pychromecast
package: platypush.plugins.media.chromecast package: platypush.plugins.media.chromecast

View File

@ -7,6 +7,9 @@ manifest:
apt: apt:
- python3-gi - python3-gi
- python3-gst-1.0 - python3-gst-1.0
dnf:
- python-gstreamer1
- python-gobject
pacman: pacman:
- gst-python - gst-python
- python-gobject - python-gobject

View File

@ -5,6 +5,8 @@ manifest:
- mplayer - mplayer
apt: apt:
- mplayer - mplayer
dnf:
- mplayer
pacman: pacman:
- mplayer - mplayer
package: platypush.plugins.media.mplayer package: platypush.plugins.media.mplayer

View File

@ -7,6 +7,8 @@ manifest:
apt: apt:
- mpv - mpv
- python3-mpv - python3-mpv
dnf:
- mpv
pacman: pacman:
- mpv - mpv
- python-mpv - python-mpv

View File

@ -7,6 +7,9 @@ manifest:
apt: apt:
- vlc - vlc
- python3-vlc - python3-vlc
dnf:
- vlc
- python3-vlc
pacman: pacman:
- vlc - vlc
pip: pip:

View File

@ -3,6 +3,8 @@ manifest:
install: install:
apt: apt:
- python3-rtmidi - python3-rtmidi
dnf:
- python-rtmidi
pacman: pacman:
- python-rtmidi - python-rtmidi
pip: pip:

View File

@ -4,12 +4,15 @@ manifest:
apk: apk:
- py3-numpy - py3-numpy
- py3-opencv - py3-opencv
pacman:
- python-numpy
- python-opencv
apt: apt:
- python3-numpy - python3-numpy
- python3-opencv - python3-opencv
dnf:
- python-numpy
- python-opencv
pacman:
- python-numpy
- python-opencv
pip: pip:
- numpy - numpy
- opencv-python - opencv-python

View File

@ -4,10 +4,12 @@ manifest:
install: install:
apk: apk:
- py3-paho-mqtt - py3-paho-mqtt
pacman:
- python-paho-mqtt
apt: apt:
- python3-paho-mqtt - python3-paho-mqtt
dnf:
- python-paho-mqtt
pacman:
- python-paho-mqtt
pip: pip:
- paho-mqtt - paho-mqtt
package: platypush.plugins.mqtt package: platypush.plugins.mqtt

View File

@ -3,6 +3,8 @@ manifest:
install: install:
apt: apt:
- python3-mpd - python3-mpd
dnf:
- python3-mpd2
pacman: pacman:
- python-mpd2 - python-mpd2
pip: pip:

View File

@ -5,6 +5,8 @@ manifest:
- py3-otp - py3-otp
apt: apt:
- python3-pyotp - python3-pyotp
dnf:
- python-pyotp
pacman: pacman:
- python-pyotp - python-pyotp
pip: pip:

View File

@ -6,6 +6,8 @@ manifest:
apt: apt:
- libcups2-dev - libcups2-dev
- python3-cups - python3-cups
dnf:
- python-cups
pacman: pacman:
- python-pycups - python-pycups
pip: pip:

View File

@ -6,16 +6,21 @@ manifest:
- py3-pillow - py3-pillow
- py3-qrcode - py3-qrcode
- py3-pyzbar - py3-pyzbar
pacman:
- python-numpy
- python-pillow
- python-qrcode
- pyzbar
apt: apt:
- python3-numpy - python3-numpy
- python3-pillow - python3-pillow
- python3-pyzbar - python3-pyzbar
- python3-qrcode - python3-qrcode
dnf:
- python-numpy
- python-pillow
- python-qrcode
- python-zbar
pacman:
- python-numpy
- python-pillow
- python-qrcode
- pyzbar
pip: pip:
- numpy - numpy
- qrcode - qrcode

View File

@ -8,6 +8,9 @@ manifest:
apt: apt:
- python3-feedparser - python3-feedparser
- python3-defusedxml - python3-defusedxml
dnf:
- python-feedparser
- python-defusedxml
pacman: pacman:
- python-feedparser - python-feedparser
- python-defusedxml - python-defusedxml

View File

@ -19,6 +19,8 @@ manifest:
- rtorrent - rtorrent
apt: apt:
- rtorrent - rtorrent
dnf:
- rtorrent
pacman: pacman:
- rtorrent - rtorrent
package: platypush.plugins.rtorrent package: platypush.plugins.rtorrent

View File

@ -6,6 +6,8 @@ manifest:
- py3-pyserial - py3-pyserial
apt: apt:
- python3-serial - python3-serial
dnf:
- python-pyserial
pacman: pacman:
- python-pyserial - python-pyserial
pip: pip:

View File

@ -17,6 +17,10 @@ manifest:
- ffmpeg - ffmpeg
- portaudio19-dev - portaudio19-dev
- python3-numpy - python3-numpy
dnf:
- ffmpeg
- portaudio-devel
- python-numpy
pacman: pacman:
- ffmpeg - ffmpeg
- portaudio - portaudio

View File

@ -5,6 +5,8 @@ manifest:
- py3-paramiko - py3-paramiko
apt: apt:
- python3-paramiko - python3-paramiko
dnf:
- python-paramiko
pacman: pacman:
- python-paramiko - python-paramiko
pip: pip:

View File

@ -8,6 +8,8 @@ manifest:
- python-sounddevice - python-sounddevice
apt: apt:
- python3-numpy - python3-numpy
dnf:
- python-numpy
pip: pip:
- deepspeech - deepspeech
- numpy - numpy

View File

@ -5,6 +5,8 @@ manifest:
- py3-py-cpuinfo - py3-py-cpuinfo
apt: apt:
- python3-cpuinfo - python3-cpuinfo
dnf:
- python-cpuinfo
pacman: pacman:
- python-py-cpuinfo - python-py-cpuinfo
pip: pip:

View File

@ -16,14 +16,17 @@ manifest:
apk: apk:
- py3-numpy - py3-numpy
- py3-pandas - py3-pandas
apt:
- python3-numpy
- python3-pandas
dnf:
- python3-numpy
- python3-pandas
pacman: pacman:
- python-numpy - python-numpy
- python-pandas - python-pandas
- python-tensorflow - python-tensorflow
- python-keras - python-keras
apt:
- python3-numpy
- python3-pandas
pip: pip:
- numpy - numpy
- pandas - pandas

View File

@ -5,6 +5,8 @@ manifest:
- py3-libtorrent-rasterbar - py3-libtorrent-rasterbar
apt: apt:
- python3-libtorrent - python3-libtorrent
dnf:
- rb_libtorrent-python3
pacman: pacman:
- libtorrent-rasterbar - libtorrent-rasterbar
pip: pip:

View File

@ -3,6 +3,8 @@ manifest:
install: install:
apt: apt:
- python3-twilio - python3-twilio
dnf:
- python-twilio
pip: pip:
- twilio - twilio
package: platypush.plugins.twilio package: platypush.plugins.twilio

View File

@ -34,6 +34,8 @@ manifest:
apt: apt:
- python3-aioxmpp - python3-aioxmpp
- python3-tz - python3-tz
dnf:
- python-pytz
pacman: pacman:
- python-pytz - python-pytz
pip: pip:

View File

@ -41,10 +41,12 @@ manifest:
install: install:
apk: apk:
- py3-paho-mqtt - py3-paho-mqtt
pacman:
- python-paho-mqtt
apt: apt:
- python3-paho-mqtt - python3-paho-mqtt
dnf:
- python-paho-mqtt
pacman:
- python-paho-mqtt
pip: pip:
- paho-mqtt - paho-mqtt
package: platypush.plugins.zigbee.mqtt package: platypush.plugins.zigbee.mqtt

View File

@ -17,12 +17,14 @@ manifest:
platypush.message.event.zwave.ZwaveValueChangedEvent: > platypush.message.event.zwave.ZwaveValueChangedEvent: >
when the value of a node on the network changes. when the value of a node on the network changes.
install: install:
apk:
- py3-paho-mqtt
pacman:
- python-paho-mqtt
apt: apt:
- python3-paho-mqtt - python3-paho-mqtt
apk:
- py3-paho-mqtt
dnf:
- python-paho-mqtt
pacman:
- python-paho-mqtt
pip: pip:
- paho-mqtt - paho-mqtt
package: platypush.plugins.zwave.mqtt package: platypush.plugins.zwave.mqtt

View File

@ -42,6 +42,7 @@ class BaseImage(Enum):
ALPINE = 'alpine' ALPINE = 'alpine'
DEBIAN = 'debian' DEBIAN = 'debian'
FEDORA = 'fedora'
UBUNTU = 'ubuntu' UBUNTU = 'ubuntu'
def __str__(self) -> str: def __str__(self) -> str:
@ -129,6 +130,15 @@ class PackageManagers(Enum):
parse_list_line=lambda line: line.split('/')[0], parse_list_line=lambda line: line.split('/')[0],
) )
DNF = PackageManager(
executable='dnf',
install=('dnf', 'install', '-y'),
uninstall=('dnf', 'remove', '-y'),
list=('dnf', 'list', '--installed'),
default_os='fedora',
parse_list_line=lambda line: re.split(r'\s+', line)[0].split('.')[0],
)
PACMAN = PackageManager( PACMAN = PackageManager(
executable='pacman', executable='pacman',
install=('pacman', '-S', '--noconfirm', '--needed'), install=('pacman', '-S', '--noconfirm', '--needed'),