~necoro/portato/0.9.0

« back to all changes in this revision

Viewing changes to portato/plugins/notify.py

  • Committer: Necoro
  • Date: 2008-03-24 22:05:07 UTC
  • Revision ID: svn-v3-trunk0:707e4503-1661-43cb-8fc9-483266be2d6d:tags%2F0.9.0.2:686
Tags: 0.9.0.2
Moved versions back to tags

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from gettext import lgettext as _
 
2
import pynotify
 
3
 
 
4
from portato import get_listener
 
5
 
 
6
from portato.helper import warning, error, debug
 
7
from portato.constants import APP_ICON, APP
 
8
 
 
9
def notify (retcode, **kwargs):
 
10
        if retcode is None:
 
11
                warning(_("Notify called while process is still running!"))
 
12
        else:
 
13
                icon = APP_ICON
 
14
                if retcode == 0:
 
15
                        text = _("Emerge finished!")
 
16
                        descr = ""
 
17
                        urgency = pynotify.URGENCY_NORMAL
 
18
                else:
 
19
                        text = _("Emerge failed!")
 
20
                        descr = _("Error Code: %d") % retcode
 
21
                        urgency = pynotify.URGENCY_CRITICAL
 
22
 
 
23
                get_listener().send_notify(base = text, descr = descr, icon = icon, urgency = urgency)