summaryrefslogtreecommitdiff
path: root/portato
diff options
context:
space:
mode:
Diffstat (limited to 'portato')
-rw-r--r--portato/backend/portage/system.py3
-rw-r--r--portato/backend/system_interface.py10
-rw-r--r--portato/gui/gtk/windows.py14
-rw-r--r--portato/gui/gui_helper.py51
-rw-r--r--portato/plugin.py23
-rw-r--r--portato/plugins/etc_proposals.py35
6 files changed, 108 insertions, 28 deletions
diff --git a/portato/backend/portage/system.py b/portato/backend/portage/system.py
index 53384dd..9cda5ab 100644
--- a/portato/backend/portage/system.py
+++ b/portato/backend/portage/system.py
@@ -85,6 +85,9 @@ class PortageSystem (SystemInterface):
return [package.PortagePackage(x) for x in list_of_packages]
+ def get_global_settings (self, key):
+ return self.settings.settings[key]
+
def find_best (self, list):
return package.PortagePackage(portage.best(list))
diff --git a/portato/backend/system_interface.py b/portato/backend/system_interface.py
index ade2414..f37d0a0 100644
--- a/portato/backend/system_interface.py
+++ b/portato/backend/system_interface.py
@@ -192,6 +192,16 @@ class SystemInterface:
raise NotImplementedError
+ def get_global_settings(self, key):
+ """Returns the value of a global setting, i.e. ARCH, USE, ROOT, DISTDIR etc.
+
+ @param key: the setting to return
+ @type key: string
+ @returns: the value of this setting
+ @rtype: string"""
+
+ raise NotImplementedError
+
def new_package (self, cpv):
"""Returns an instance of the appropriate Package-Subclass.
diff --git a/portato/gui/gtk/windows.py b/portato/gui/gtk/windows.py
index d67bcfd..a27d156 100644
--- a/portato/gui/gtk/windows.py
+++ b/portato/gui/gtk/windows.py
@@ -24,7 +24,7 @@ from portato.backend import flags, system
from portato.backend.exceptions import *
# plugins
-from portato.plugin import PluginQueue
+from portato import plugin
# more GUI stuff
from portato.gui.gui_helper import Database, Config, EmergeQueue
@@ -626,7 +626,7 @@ class PackageTable:
return True
def cb_package_ebuild_clicked(self, button):
- hook = self.main.pluginQueue.hook("open_ebuild", self.actual_package(), self.window)
+ hook = plugin.hook("open_ebuild", self.actual_package(), self.window)
hook(EbuildWindow)(self.window, self.actual_package())
return True
@@ -720,8 +720,7 @@ class MainWindow (Window):
self.cfg.modify_external_configs()
- # plugins
- self.pluginQueue = PluginQueue()
+ plugin.load_plugins()
# set vpaned position
vpaned = self.tree.get_widget("vpaned")
@@ -1020,7 +1019,12 @@ class MainWindow (Window):
return True
def cb_about_clicked (self, button):
- AboutWindow(self.window, self.pluginQueue.get_plugin_data())
+ queue = plugin.get_plugins()
+ if queue is None:
+ queue = []
+ else:
+ queue = queue.get_plugin_data()
+ AboutWindow(self.window, queue)
return True
def cb_right_click (self, object, event):
diff --git a/portato/gui/gui_helper.py b/portato/gui/gui_helper.py
index 79064b6..ecc3ba6 100644
--- a/portato/gui/gui_helper.py
+++ b/portato/gui/gui_helper.py
@@ -14,6 +14,7 @@
from portato import backend
from portato.backend import flags, system, set_system
from portato.helper import *
+from portato import plugin
# parser
from portato.config_parser import ConfigParser
@@ -280,7 +281,7 @@ class EmergeQueue:
self.db = db
self.title_update = title_update
-
+
# our iterators pointing at the toplevels; they are set to None if we do not have a tree
if self.tree:
self.emergeIt = self.tree.get_emerge_it()
@@ -455,11 +456,15 @@ class EmergeQueue:
if self.title_update: self.title_update(None)
- for p in packages:
- if p in ["world", "system"]: continue
- cat = system.split_cpv(p)[0] # get category
- self.db.reload(cat)
- debug("Category %s refreshed" % cat)
+ @plugin.hook("after_emerge", packages)
+ def update_packages():
+ for p in packages:
+ if p in ["world", "system"]: continue
+ cat = system.split_cpv(p)[0] # get category
+ self.db.reload(cat)
+ debug("Category %s refreshed" % cat)
+
+ update_packages()
def _emerge (self, options, packages, it, command = None):
"""Calls emerge and updates the terminal.
@@ -473,22 +478,26 @@ class EmergeQueue:
@param command: the command to execute - default is "/usr/bin/python /usr/bin/emerge"
@type command: string[]"""
- if command is None:
- command = system.get_merge_command()
+ @plugin.hook("emerge", packages, command)
+ def sub_emerge(command):
+ if command is None:
+ command = system.get_merge_command()
- # open tty
- (master, slave) = pty.openpty()
- self.console.set_pty(master)
-
- # start emerge
- self.process = Popen(command+options+packages, stdout = slave, stderr = STDOUT, shell = False)
-
- # start thread waiting for the stop of emerge
- Thread(name="Emerge-Thread", target=self._update_packages, args=(packages+self.deps.keys(), self.process)).start()
-
- # remove
- for i in it:
- self.remove_with_children(i)
+ # open tty
+ (master, slave) = pty.openpty()
+ self.console.set_pty(master)
+
+ # start emerge
+ self.process = Popen(command+options+packages, stdout = slave, stderr = STDOUT, shell = False)
+
+ # start thread waiting for the stop of emerge
+ Thread(name="Emerge-Thread", target=self._update_packages, args=(packages+self.deps.keys(), self.process)).start()
+
+ # remove
+ for i in it:
+ self.remove_with_children(i)
+
+ sub_emerge(command)
def emerge (self, force = False):
"""Emerges everything in the merge-queue.
diff --git a/portato/plugin.py b/portato/plugin.py
index 4d49fc9..4ce4099 100644
--- a/portato/plugin.py
+++ b/portato/plugin.py
@@ -243,7 +243,7 @@ class PluginQueue:
else:
list = ([],[],[])
- def wrapper (self, *args, **kwargs):
+ def wrapper (*args, **kwargs):
# before
for cmd in list[0]:
@@ -254,7 +254,7 @@ class PluginQueue:
debug("Overriding hook '%s' with plugin '%s'" % (hook, list[1][0].hook.plugin.name))
call(list[1][0])
else: # normal
- func(self, *args, **kwargs)
+ func(*args, **kwargs)
# after
for cmd in list[2]:
@@ -368,3 +368,22 @@ class PluginQueue:
for hook in after:
resolve(hook, after[hook], 2, 1)
+
+
+__plugins = None
+
+def load_plugins():
+ global __plugins
+ if __plugins is None:
+ __plugins = PluginQueue()
+
+def get_plugins():
+ return __plugins
+
+def hook(hook, *args, **kwargs):
+ if __plugins is None:
+ def pseudo_decorator(f):
+ return f
+ return pseudo_decorator
+ else:
+ return __plugins.hook(hook, *args, **kwargs)
diff --git a/portato/plugins/etc_proposals.py b/portato/plugins/etc_proposals.py
new file mode 100644
index 0000000..bf58c06
--- /dev/null
+++ b/portato/plugins/etc_proposals.py
@@ -0,0 +1,35 @@
+# -*- coding: utf-8 -*-
+#
+# File: portato/plugins/etc_proposals.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 <necoro@necoro.net>
+
+from portato.helper import debug
+from portato.backend import system
+
+import os
+from etcproposals.etcproposals_lib import EtcProposals
+
+class PortatoEtcProposals(EtcProposals):
+ """Subclassed EtcProposals using portato.backend.system during __init__."""
+
+ def refresh(self):
+ self.clear_cache()
+ del self[:]
+ for dir in system.get_global_settings("CONFIG_PROTECT").split():
+ self._add_update_proposals(dir)
+ self.sort()
+
+def etc_prop (*args, **kwargs):
+ """Entry point for this plugin."""
+ l = len(PortatoEtcProposals())
+ debug(l,"files to update")
+
+ if l > 0:
+ os.system("etc-proposals")