From ade10e0b8e5571e45cdd4800927c24597e2f7315 Mon Sep 17 00:00:00 2001 From: necoro <> Date: Sun, 12 Aug 2007 04:21:38 +0000 Subject: added listener/notify --- portato/plugins/etc_proposals.py | 3 ++- portato/plugins/noroot.py | 15 --------------- portato/plugins/notify.py | 23 +++++++++++++++++++++++ 3 files changed, 25 insertions(+), 16 deletions(-) delete mode 100644 portato/plugins/noroot.py create mode 100644 portato/plugins/notify.py (limited to 'portato/plugins') diff --git a/portato/plugins/etc_proposals.py b/portato/plugins/etc_proposals.py index 81370e0..f094599 100644 --- a/portato/plugins/etc_proposals.py +++ b/portato/plugins/etc_proposals.py @@ -13,6 +13,7 @@ from portato.helper import * from portato.backend import system +import os from subprocess import Popen from gettext import lgettext as _ from etcproposals.etcproposals_lib import EtcProposals, __version__ @@ -64,7 +65,7 @@ def etc_prop (*args, **kwargs): error(_("Cannot start etc-proposals. No graphical frontend installed!")) def etc_prop_menu (*args, **kwargs): - if am_i_root(): + if os.getuid() == 0: if float(__version__) < 1.1: Popen(PROG) else: diff --git a/portato/plugins/noroot.py b/portato/plugins/noroot.py deleted file mode 100644 index a28ef85..0000000 --- a/portato/plugins/noroot.py +++ /dev/null @@ -1,15 +0,0 @@ -# -*- coding: utf-8 -*- -# -# File: portato/plugins/noroot.py -# This file is part of the Portato-Project, a graphical portage-frontend. -# -# Copyright (C) 2007 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 - -def i_am_root (*args): - """Pretend we are root.""" - return True diff --git a/portato/plugins/notify.py b/portato/plugins/notify.py new file mode 100644 index 0000000..5e4a577 --- /dev/null +++ b/portato/plugins/notify.py @@ -0,0 +1,23 @@ +from gettext import lgettext as _ +import pynotify + +from portato import listener + +from portato.helper import warning, error, debug +from portato.constants import APP_ICON, APP + +def notify (retcode, **kwargs): + if retcode is None: + warning(_("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 + + listener.send_notify(base = text, descr = descr, icon = icon, urgency = urgency) -- cgit v1.2.3-54-g00ecf