Skip to content

Commit

Permalink
Merge pull request #365 from alxbl/py-notify
Browse files Browse the repository at this point in the history
chore(363): replace notify2 by py-notifier
  • Loading branch information
obilodeau authored Nov 26, 2021
2 parents 933ca2a + ba29271 commit 287e617
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
- name: Install setuptools
run: sudo apt install python3-setuptools
- name: Install PyRDP dependencies
run: sudo apt install libdbus-1-dev libdbus-glib-1-dev libgl1-mesa-glx git python3-dev
run: sudo apt install libgl1-mesa-glx git python3-dev
- name: Install wheel
working-directory: .
run: pip install wheel
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
python3-setuptools \
# Required for venv setup
python3-venv \
# Required to build RLE module and dbus-python (GUI)
# Required to build RLE module
build-essential python3-dev \
libdbus-1-dev libdbus-glib-1-dev \
# Required to build PyAV (pyrdp-convert to MP4)
libavformat-dev libavcodec-dev libavdevice-dev \
libavutil-dev libswscale-dev libswresample-dev libavfilter-dev
Expand Down Expand Up @@ -47,7 +46,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends python3 \
python3-distutils \
# GUI and notifications stuff
libgl1-mesa-glx libxcb-xinerama0 \
notify-osd dbus-x11 libxkbcommon-x11-0 \
libxkbcommon-x11-0 \
libnotify-bin \
# Runtime requirement for PyAV (pyrdp-convert to MP4)
libavcodec58 libavdevice58 \
&& rm -rf /var/lib/apt/lists/*
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,9 @@ slim one. Install the dependencies according to your use case.
# Full install (GUI, transcoding to MP4)
sudo apt install python3 python3-pip python3-dev python3-setuptools python3-venv \
build-essential python3-dev git openssl \
libdbus-1-dev libdbus-glib-1-dev libgl1-mesa-glx \
notify-osd dbus-x11 libxkbcommon-x11-0 libxcb-xinerama0 \
libgl1-mesa-glx \
libnotify-bin \
libxkbcommon-x11-0 libxcb-xinerama0 \
libavformat-dev libavcodec-dev libavdevice-dev \
libavutil-dev libswscale-dev libswresample-dev libavfilter-dev
Expand Down
15 changes: 11 additions & 4 deletions pyrdp/logging/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

# Dependency not installed on Windows. Notifications are not supported
try:
import notify2
from pynotifier import Notification
except ImportError:
pass

Expand All @@ -18,13 +18,20 @@ class NotifyHandler(logging.StreamHandler):
"""

def __init__(self):
notify2.init("pyrdp-player")
super(NotifyHandler, self).__init__()

def emit(self, record):
"""
Send a notification.
:param record: the LogRecord object
"""
notification = notify2.Notification(record.getMessage())
notification.show()
try:
Notification(
title='PyRDP',
description=record.getMessage(),
# duration=5, # seconds
urgency='normal'
).send()
except:
# Either libnotify-bin is not installed or the platform does not support notifications.
pass
4 changes: 2 additions & 2 deletions pyrdp/player/player.default.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# On Windows systems, the file should be in:
#
# %APPDATA%/pyrdp/player.ini
#
#
# On MacOS:
#
# ~/Library/Application Support/pyrdp/player.ini
Expand Down Expand Up @@ -62,7 +62,7 @@ version = 1
filter = pyrdp

# Enable notifications.
# This requires a supported operating system with DBus and a
# This requires a supported operating system with libnotify-bin and a
# notification daemon.
notifications = True

Expand Down
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ av==8.0.3
cffi==1.14.6
constantly==15.1.0
cryptography==3.4.7
dbus-python==1.2.16
hyperlink==21.0.0
idna==3.2
incremental==21.3.0
names==0.3.0
notify2==0.3.1
progressbar2==3.53.1
pyasn1==0.4.8
pyasn1-modules==0.2.8
Expand All @@ -29,3 +27,4 @@ six==1.16.0
Twisted==21.7.0
typing-extensions==3.10.0.0
zope.interface==5.4.0
py-notifier==0.3.2
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
'av>=8',
'PySide2>=5.12,<6',
'qimage2ndarray>=1.6',
'dbus-python>=1.2<1.3;platform_system!="Windows"',
'notify2>=0.3,<1;platform_system!="Windows"'
'py-notifier>=0.3.0',
'win10toast>=0.9;platform_system=="Windows"',
]
}
)

0 comments on commit 287e617

Please sign in to comment.