OS X crash when sending notification #6

Closed
opened 2017-11-16 13:29:16 +03:00 by RomanZhilich · 12 comments
RomanZhilich commented 2017-11-16 13:29:16 +03:00 (Migrated from github.com)

Hello.

I got the following crash on OS X 10.11 when there's unread letters:

Traceback (most recent call last):
  File "./mail-notifier.py", line 468, in <module>
    mail_check()
  File "./mail-notifier.py", line 414, in mail_check
    notify ("You have "+ str(mail_count) +" unread letters")
  File "./mail-notifier.py", line 442, in notify
    subprocess.Popen(['notify-send', programTitle, message])
  File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 709, in __init__
    restore_signals, start_new_session)
  File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 1344, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'notify-send': 'notify-send'

I might be missing some dependencies but the only one required according to Readme is PyQt5 which I have installed via Homebrew.

Hello. I got the following crash on OS X 10.11 when there's unread letters: ``` Traceback (most recent call last): File "./mail-notifier.py", line 468, in <module> mail_check() File "./mail-notifier.py", line 414, in mail_check notify ("You have "+ str(mail_count) +" unread letters") File "./mail-notifier.py", line 442, in notify subprocess.Popen(['notify-send', programTitle, message]) File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 709, in __init__ restore_signals, start_new_session) File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 1344, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: 'notify-send': 'notify-send' ``` I might be missing some dependencies but the only one required according to Readme is PyQt5 which I have installed via Homebrew.
rinaldus commented 2017-11-16 14:05:12 +03:00 (Migrated from github.com)

Please, check my last commit 6ccb04632b. It seems that OS X have not 'notify-send' command. I changed the way to send notifications. Now the program requires additional library notify2 as dependency. Install it and it should be work.

Please, check my last commit 6ccb04632b9fa2abb9223c254b3d1451b76e2bd1. It seems that OS X have not 'notify-send' command. I changed the way to send notifications. Now the program requires additional library [notify2](https://pypi.python.org/pypi/notify2) as dependency. Install it and it should be work.
RomanZhilich commented 2017-11-16 14:13:12 +03:00 (Migrated from github.com)

Thanks for prompt response. I pulled latest changes, installed notify2, and now I get following error:

  File "/usr/local/lib/python3.6/site-packages/notify2.py", line 39, in <module>
    import dbus
ModuleNotFoundError: No module named 'dbus'

There are some people having similar problems i.e. https://stackoverflow.com/questions/37521162/how-solve-importerror-no-module-named-dbus
But none of the proposed solutions worked for me, including installing dbus package via Homebrew.

Thanks for prompt response. I pulled latest changes, installed `notify2`, and now I get following error: ``` File "/usr/local/lib/python3.6/site-packages/notify2.py", line 39, in <module> import dbus ModuleNotFoundError: No module named 'dbus' ``` There are some people having similar problems i.e. https://stackoverflow.com/questions/37521162/how-solve-importerror-no-module-named-dbus But none of the proposed solutions worked for me, including installing `dbus` package via Homebrew.
rinaldus commented 2017-11-16 14:35:36 +03:00 (Migrated from github.com)

Try to install the program in virtualenv. Follow the instructions to install virtualenv, activate it and install PyQt5, notify2 and probably dbus inside of virtualenv.

Try to install the program in [virtualenv](http://sourabhbajaj.com/mac-setup/Python/virtualenv.html). Follow the instructions to install virtualenv, activate it and install `PyQt5`, `notify2` and probably `dbus` inside of virtualenv.
rinaldus commented 2017-11-16 14:41:23 +03:00 (Migrated from github.com)

But none of the proposed solutions worked for me, including installing dbus package via Homebrew.

Did you try to install dbus-python via pip?

> But none of the proposed solutions worked for me, including installing `dbus` package via Homebrew. Did you try to install [dbus-python](https://pypi.python.org/pypi/dbus-python) via pip?
RomanZhilich commented 2017-11-16 14:50:10 +03:00 (Migrated from github.com)

Did you try to install dbus-python via pip?

Installation fails without clear reason and a lot of junk output. I'm trying to dig through logs..
It seems there was relevant package in Homebrew but it got removed at some point. There are some outdated instructions online that recommend installing brew install homebrew/python/python-dbus
I'll try downloading sources and installing it manually

>Did you try to install dbus-python via pip? Installation fails without clear reason and a lot of junk output. I'm trying to dig through logs.. It seems there was relevant package in Homebrew but it got removed at some point. There are some outdated instructions online that recommend installing `brew install homebrew/python/python-dbus ` I'll try downloading sources and installing it manually
RomanZhilich commented 2017-11-16 15:19:36 +03:00 (Migrated from github.com)

I've made some progress but it still doesn't work.
To properly use notify2 on OS X you have to install dbus with Homebrew:

brew install pkg-config dbus dbus-glib  
brew services start dbus

Then:

pip3 install notify2 dbus-python

But I still have an error when trying to launch mail-notifier.py:

dbus.exceptions.DBusException: org.freedesktop.DBus.Error.NameHasNoOwner: Could not get owner of name 'org.freedesktop.Notifications': no such name

It seems that dbus service is not properly registered in the system. Other people had this problem https://github.com/fr31/spotifylyrics/issues/19#issuecomment-242543039 but no workaround as far as I can tell.

I've made some progress but it still doesn't work. To properly use `notify2` on OS X you have to install `dbus` with Homebrew: ``` brew install pkg-config dbus dbus-glib brew services start dbus ``` Then: ``` pip3 install notify2 dbus-python ``` But I still have an error when trying to launch `mail-notifier.py`: ``` dbus.exceptions.DBusException: org.freedesktop.DBus.Error.NameHasNoOwner: Could not get owner of name 'org.freedesktop.Notifications': no such name ``` It seems that dbus service is not properly registered in the system. Other people had this problem https://github.com/fr31/spotifylyrics/issues/19#issuecomment-242543039 but no workaround as far as I can tell.
rinaldus commented 2017-11-16 15:45:48 +03:00 (Migrated from github.com)

I made quick fix to prevent crashing if OS notification is different than Linux. Baloon notification won't work, but it will print notification to console output (better, than nothing) instead and it won't crash. Please, test this commit.
I will continue to work on this problem, but I'm not sure, that I succeed to resolve it and it won't be soon.

I made quick [fix](c025371c1b2daae86b8b32bc9ca3bf2c07fb43c5) to prevent crashing if OS notification is different than Linux. Baloon notification won't work, but it will print notification to console output (better, than nothing) instead and it won't crash. Please, test this commit. I will continue to work on this problem, but I'm not sure, that I succeed to resolve it and it won't be soon.
RomanZhilich commented 2017-11-16 15:53:57 +03:00 (Migrated from github.com)

Please, test this commit.

It still crashes because right now notify2 initialization is the problem. You'll have to make it conditional, probably including import notify2 which I'm not sure how to do...

I will continue to work on this problem

I will also try to resolve service error and update this issue if I find a solution.

>Please, test this commit. It still crashes because right now notify2 initialization is the problem. You'll have to make it conditional, probably including `import notify2` which I'm not sure how to do... >I will continue to work on this problem I will also try to resolve service error and update this issue if I find a solution.
rinaldus commented 2017-11-16 16:29:03 +03:00 (Migrated from github.com)

Ok, I came back to first notification method (which using notify-send), but added try: ... except: ... to prevent crashing. Please, check b04cb9a6ff, is it workable? You should see notification in terminal output instead of baloon.

Ok, I came back to first notification method (which using `notify-send`), but added try: ... except: ... to prevent crashing. Please, check b04cb9a6ffc275b723caa402f21fe8e65256ad84, is it workable? You should see notification in terminal output instead of baloon.
RomanZhilich commented 2017-11-16 16:42:30 +03:00 (Migrated from github.com)

Yes, this is working.
Thanks.

Yes, this is working. Thanks.
rinaldus commented 2017-11-16 17:03:35 +03:00 (Migrated from github.com)

I have one idea how to solve this problem, but I need to install OS X in Virtual Box and understand how it works there. It will take some time.

I have one idea how to solve this problem, but I need to install OS X in Virtual Box and understand how it works there. It will take some time.
RomanZhilich commented 2017-11-16 17:05:41 +03:00 (Migrated from github.com)

Thanks, I'll keep an eye out for updates.
But I think this issue should be closed. The crash was a bug, and it's fixed now that you handle OS X notifications issue gracefully.

Thanks, I'll keep an eye out for updates. But I think this issue should be closed. The crash was a bug, and it's fixed now that you handle OS X notifications issue gracefully.
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: Rinaldus/mail-notifier#6
No description provided.