~ubuntu-branches/debian/stretch/electrum/stretch

« back to all changes in this revision

Viewing changes to gui/kivy/tools/.buildozer/android/platform/python-for-android/dist/kivy/python-install/lib/python2.7/site-packages/plyer/platforms/linux/notification.py

  • Committer: Package Import Robot
  • Author(s): Tristan Seligmann
  • Date: 2016-04-04 03:02:39 UTC
  • mfrom: (1.1.10)
  • Revision ID: package-import@ubuntu.com-20160404030239-0szgkio8yryjv7c9
Tags: 2.6.3-1
* New upstream release.
  - Drop backported install-wizard-connect.patch.
* Add Suggests: python-zbar and update the installation hint to suggest
  apt-get instead of pip (closes: #819517).
* Bump Standards-Version to 3.9.7 (no changes).
* Update Vcs-* links.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import subprocess
 
2
from plyer.facades import Notification
 
3
from plyer.utils import whereis_exe
 
4
 
 
5
 
 
6
class NotifySendNotification(Notification):
 
7
    ''' Pops up a notification using notify-send
 
8
    '''
 
9
    def _notify(self, **kwargs):
 
10
        subprocess.call(["notify-send",
 
11
                         kwargs.get('title'),
 
12
                         kwargs.get('message')])
 
13
 
 
14
 
 
15
class NotifyDbus(Notification):
 
16
    ''' notify using dbus interface
 
17
    '''
 
18
 
 
19
    def _notify(self, **kwargs):
 
20
        summary = kwargs.get('title', "title")
 
21
        body = kwargs.get('message', "body")
 
22
        app_name = kwargs.get('app_name', '')
 
23
        app_icon = kwargs.get('app_icon', '')
 
24
        timeout = kwargs.get('timeout', 5000)
 
25
        actions = kwargs.get('actions', [])
 
26
        hints = kwargs.get('hints', [])
 
27
        replaces_id = kwargs.get('replaces_id', 0)
 
28
 
 
29
        _bus_name = 'org.freedesktop.Notifications'
 
30
        _object_path = '/org/freedesktop/Notifications'
 
31
        _interface_name = _bus_name
 
32
 
 
33
        import dbus
 
34
        session_bus = dbus.SessionBus()
 
35
        obj = session_bus.get_object(_bus_name, _object_path)
 
36
        interface = dbus.Interface(obj, _interface_name)
 
37
        interface.Notify(app_name, replaces_id, app_icon,
 
38
            summary, body, actions, hints, timeout)
 
39
 
 
40
 
 
41
def instance():
 
42
    import sys
 
43
    try:
 
44
        import dbus
 
45
        return NotifyDbus()
 
46
    except ImportError:
 
47
        sys.stderr.write("python-dbus not installed. try:"
 
48
                         "`sudo pip install python-dbus`.")
 
49
    if whereis_exe('notify-send'):
 
50
        return NotifySendNotification()
 
51
    sys.stderr.write("notify-send not found.")
 
52
    return Notification()