summaryrefslogtreecommitdiff
path: root/plugins/notify.py
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.net>2008-07-08 15:00:20 +0200
committerRené 'Necoro' Neumann <necoro@necoro.net>2008-07-08 15:00:20 +0200
commit276451a383052ffdc67f561082825cc84aa83bd7 (patch)
treea148e31c8d201ecc61903eae18a495b9cfdf80be /plugins/notify.py
parent0a8814713917548767f0ff823e34d412061b3ffe (diff)
parent8b6db38a2d27fca00d0fe037e86eefc941d559e4 (diff)
downloadportato-276451a383052ffdc67f561082825cc84aa83bd7.tar.gz
portato-276451a383052ffdc67f561082825cc84aa83bd7.tar.bz2
portato-276451a383052ffdc67f561082825cc84aa83bd7.zip
Merged in the new plugin system
Diffstat (limited to '')
-rw-r--r--plugins/notify.py49
1 files changed, 49 insertions, 0 deletions
diff --git a/plugins/notify.py b/plugins/notify.py
new file mode 100644
index 0000000..6446812
--- /dev/null
+++ b/plugins/notify.py
@@ -0,0 +1,49 @@
+# -*- coding: utf-8 -*-
+#
+# File: plugins/notify.py
+# This file is part of the Portato-Project, a graphical portage-frontend.
+#
+# Copyright (C) 2007-2008 René 'Necoro' Neumann
+# This is free software. You may redistribute copies of it under the terms of
+# the GNU General Public License version 2.
+# There is NO WARRANTY, to the extent permitted by law.
+#
+# Written by René 'Necoro' Neumann <necoro@necoro.net>
+
+disable = False
+
+try:
+ import pynotify
+except ImportError:
+ disable = True
+
+from portato import get_listener
+
+from portato.helper import warning, error, debug
+from portato.constants import APP_ICON, APP
+
+class Notify (Plugin):
+ __author__ = "René 'Necoro' Neumann"
+ __description__ = "Show notifications when an emerge process finishes."
+ __dependency__ = ["dev-python/notify-python"]
+
+ def init (self):
+ self.add_call("after_emerge", self.notify)
+
+ def notify (self, retcode, **kwargs):
+ if retcode is None:
+ warning("NOTIFY :: %s", _("Notify called while process is still running!"))
+ else:
+ icon = APP_ICON
+ if retcode == 0:
+ text = _("Emerge finished!")
+ descr = ""
+ urgency = pynotify.URGENCY_NORMAL
+ else:
+ text = _("Emerge failed!")
+ descr = _("Error Code: %d") % retcode
+ urgency = pynotify.URGENCY_CRITICAL
+
+ get_listener().send_notify(base = text, descr = descr, icon = icon, urgency = urgency)
+
+register(Notify, disable)