Eu gostaria de integrar dentro do programa U-U python uma notificação DE. Primeiro de tudo eu tentei notify2 de linha de comando python3 e isso é OK. Funciona:
$ python3
Python 3.4.2 (default, Oct 8 2014, 10:45:20)
[GCC 4.9.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import notify2
>>> notify2.init('foo')
True
>>> n= notify2.Notification('foo','bar')
>>> n.show()
True
Além disso, um único arquivo test.py funciona bem; mas quando eu coloco estas linhas em uma funcion dentro do arquivo python U-U assim:
def my_notification_on_de(mytext):
notify2.init('TEST')
n = notify2.Notification('TEST', mytext)
n.show()
.....
into U-U main program
.....
# exit if there is nothing to do and nothing to report
if (len(pkgs_to_upgrade) == 0) and (len(pkgs_kept_back) == 0):
logging.info(_("No packages found that can be upgraded unattende$
# Added from me
my_notification_on_de("NO update found!")
.....
return
Eu recebi esta mensagem:
No packages found that can be upgraded unattended
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/dbus/bus.py", line 175, in
activate_name_owner
return self.get_name_owner(bus_name)
File "/usr/lib/python3/dist-packages/dbus/bus.py", line 361, in
get_name_owner
's', (bus_name,), **keywords)
File "/usr/lib/python3/dist-packages/dbus/connection.py", line 651, in
call_blocking
message, timeout)
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.NameHasNoOwner:
Could not get owner of name 'org.freedesktop.Notifications': no such name
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/bin/unattended-upgrade", line 1378, in <module>
main(options)
File "/usr/bin/unattended-upgrade", line 1272, in main
my_notification_on_de("NO update found!")
File "/usr/bin/unattended-upgrade", line 1061, in my_notification_on_de
notify2.init('TEST')
File "/usr/lib/python3/dist-packages/notify2.py", line 96, in init
'/org/freedesktop/Notifications')
File "/usr/lib/python3/dist-packages/dbus/bus.py", line 241, in
get_object
follow_name_owner_changes=follow_name_owner_changes)
File "/usr/lib/python3/dist-packages/dbus/proxies.py", line 248, in
__init__
self._named_service = conn.activate_name_owner(bus_name)
File "/usr/lib/python3/dist-packages/dbus/bus.py", line 180, in
activate_name_owner
self.start_service_by_name(bus_name)
File "/usr/lib/python3/dist-packages/dbus/bus.py", line 278, in
start_service_by_name
'su', (bus_name, flags)))
File "/usr/lib/python3/dist-packages/dbus/connection.py", line 651, in
call_blocking
message, timeout)
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.ServiceUnknown:
The name org.freedesktop.Notifications was not provided by any .service
files
Então, por que o U-U enviou ao D-Bus minha mensagem onde não havia um serviço de notificação, mas meu teste anterior estava OK?