Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(363): replace notify2 by py-notifier #365

Merged
merged 4 commits into from
Nov 26, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends python3 \
# GUI and notifications stuff
libgl1-mesa-glx libxcb-xinerama0 \
notify-osd dbus-x11 libxkbcommon-x11-0 \
libnotify-bin \
# Runtime requirement for PyAV (pyrdp-convert to MP4)
libavcodec58 libavdevice58 \
&& rm -rf /var/lib/apt/lists/*
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ slim one. Install the dependencies according to your use case.
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 \
libnotify-bin notify-osd \
alxbl marked this conversation as resolved.
Show resolved Hide resolved
dbus-x11 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
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ 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 +28,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"',
alxbl marked this conversation as resolved.
Show resolved Hide resolved
'notify2>=0.3,<1;platform_system!="Windows"'
'py-notifier>=0.3.0',
'win10toast>=0.9;platform_system=="Windows"',
]
}
)