diff options
Diffstat (limited to '')
-rw-r--r-- | geneticone/backend/__init__.py | 1 | ||||
-rw-r--r-- | geneticone/backend/flags.py | 23 | ||||
-rw-r--r-- | geneticone/backend/package.py | 43 | ||||
-rw-r--r-- | geneticone/gui/gui_helper.py | 5 | ||||
-rw-r--r-- | geneticone/gui/windows.py | 79 | ||||
-rw-r--r-- | obsolete/geneticthread.c | 62 | ||||
-rw-r--r-- | obsolete/helper.py | 45 |
7 files changed, 113 insertions, 145 deletions
diff --git a/geneticone/backend/__init__.py b/geneticone/backend/__init__.py index 16c3a2e..5238765 100644 --- a/geneticone/backend/__init__.py +++ b/geneticone/backend/__init__.py @@ -20,6 +20,7 @@ import portage # this is set to "var/lib/portage/world" by default - so we add the leading / portage.WORLD_FILE = "/"+portage.WORLD_FILE +portage.settings = None # portage tree vars porttree = gentoolkit.porttree diff --git a/geneticone/backend/flags.py b/geneticone/backend/flags.py index 1251bfd..2da0a94 100644 --- a/geneticone/backend/flags.py +++ b/geneticone/backend/flags.py @@ -468,6 +468,26 @@ TESTING_PATH_IS_DIR = os.path.isdir(TESTING_PATH) newTesting = {} arch = "" +def remove_new_testing (cpv): + if isinstance(cpv, package.Package): + cpv = cpv.get_cpv() + + try: + del newTesting[cpv] + except KeyError: + pass + +def new_testing_status (cpv): + if isinstance(cpv, package.Package): + cpv = cpv.get_cpv() + + if cpv in newTesting: + for file, line in newTesting[cpv]: + if line == "-1": return False + else: return True + + return None + def set_testing (pkg, enable): """Enables the package for installing when it is marked as testing (~ARCH). @param pkg: the package @@ -484,12 +504,11 @@ def set_testing (pkg, enable): if not cpv in newTesting: newTesting[cpv] = [] - debug("arch: "+arch) for file, line in newTesting[cpv]: if (enable and line != "-1") or (not enable and line == "-1"): newTesting[cpv].remove((file, line)) - if (enable and (pkg.get_mask_status() % 3 == 0)) or (not enable and (pkg.get_mask_status() % 3 != 0)): + if (enable and not pkg.is_testing(allowed=True)) or (not enable and pkg.is_testing(allowed=True)): return if not enable: diff --git a/geneticone/backend/package.py b/geneticone/backend/package.py index fec346d..7b917a8 100644 --- a/geneticone/backend/package.py +++ b/geneticone/backend/package.py @@ -30,25 +30,33 @@ class Package (gentoolkit.Package): if isinstance(cpv, gentoolkit.Package): cpv = cpv.get_cpv() gentoolkit.Package.__init__(self, cpv) + self._status = portage.getmaskingstatus(self.get_cpv(), settings = gentoolkit.settings) - def get_mask_status(self): - """Gets the numeric mask status of a package. The return value can be translated as a string when taking the following list of modes: [ " ", " ~", " -", "M ", "M~", "M-" ] + def is_missing_keyword(self): + if "missing keyword" in self._status: + return True + return False - This method adapted from equery 0.1.4 - Original author: Karl Trygve Kalleberg <karltk@gentoo.org> + def is_testing(self, allowed = False): + testArch = "~" + self.get_settings("ARCH") + if not allowed: + if testArch in self.get_env_var("KEYWORDS").split(): + return True + return False + else: + status = flags.new_testing_status(self.get_cpv()) + if status == None: + if testArch+" keyword" in self._status: + return True + return False + else: + return status + + def set_testing(self, enable = True): + flags.set_testing(self, enable) - @returns: mask status - @rtype: int""" - - pkgmask = 0 - if self.is_masked(): - pkgmask = pkgmask + 3 - keywords = self.get_env_var("KEYWORDS").split() - if "~" + gentoolkit.settings["ARCH"] in keywords: - pkgmask = pkgmask + 1 - elif "-*" in keywords or "-" + gentoolkit.settings["ARCH"] in keywords: - pkgmask = pkgmask + 2 - return pkgmask + def remove_new_testing(self): + flags.remove_new_testing(self.get_cpv()) def is_masked (self): """Returns True if either masked by package.mask or by profile. @@ -62,8 +70,7 @@ class Package (gentoolkit.Package): else: debug("BUG in flags.new_masking_status. It returns "+status) else: - status = portage.getmaskingstatus(self._cpv, settings = gentoolkit.settings) - if "profile" in status or "package.mask" in status: + if "profile" in self._status or "package.mask" in self._status: return True return False diff --git a/geneticone/gui/gui_helper.py b/geneticone/gui/gui_helper.py index b5683d2..2120ea3 100644 --- a/geneticone/gui/gui_helper.py +++ b/geneticone/gui/gui_helper.py @@ -328,7 +328,10 @@ class EmergeQueue: self.mergequeue.remove(cpv) except ValueError: # this is a dependency - ignore pass - if removeNewFlags: flags.remove_new_use_flags(cpv) + if removeNewFlags: + flags.remove_new_use_flags(cpv) + flags.remove_new_masked(cpv) + flags.remove_new_testing(cpv) else: # in Unmerge self.unmergequeue.remove(cpv) diff --git a/geneticone/gui/windows.py b/geneticone/gui/windows.py index 9bdc771..1837b99 100644 --- a/geneticone/gui/windows.py +++ b/geneticone/gui/windows.py @@ -194,6 +194,7 @@ class PackageWindow (AbstractDialog): # version-combo-box self.vCombo = self.build_vers_combo() self.table.attach(self.vCombo, 0, 1, 1, 2, yoptions = gtk.FILL) + if not self.doEmerge: self.vCombo.set_sensitive(False) # the label (must be here, because it depends on the combo box) desc = self.actual_package().get_env_var("DESCRIPTION") @@ -215,19 +216,27 @@ class PackageWindow (AbstractDialog): self.installedCheck = gtk.CheckButton() self.installedCheck.connect("button-press-event", self.cb_button_pressed) - self.installedCheck.set_label("Installed") + self.installedCheck.set_label("Installed") + self.installedCheck.set_no_show_all(True) checkHB.pack_start(self.installedCheck, True, False) self.maskedCheck = gtk.CheckButton() self.maskedCheck.connect("toggled", self.cb_masked_toggled) self.maskedCheck.set_label("Masked") + self.maskedCheck.set_no_show_all(True) checkHB.pack_start(self.maskedCheck, True, False) self.testingCheck = gtk.CheckButton() - self.testingCheck.connect("button-press-event", self.cb_button_pressed) + self.testingCheck.connect("toggled", self.cb_testing_toggled) self.testingCheck.set_label("Testing") + self.testingCheck.set_no_show_all(True) checkHB.pack_start(self.testingCheck, True, False) + self.missing_label = gtk.Label("<span foreground='red'><b>MISSING KEYWORD</b></span>") + self.missing_label.set_use_markup(True) + self.missing_label.set_no_show_all(True) + self.table.attach(self.missing_label, 1, 2, 1, 2, yoptions = gtk.FILL) + # use list self.useList = self.build_use_list() self.useListScroll = gtk.ScrolledWindow() @@ -242,7 +251,7 @@ class PackageWindow (AbstractDialog): self.emergeBtn = gtk.Button("_Emerge") self.unmergeBtn = gtk.Button("_Unmerge") - if not self.queue or not doEmerge: + if not self.queue or not self.doEmerge: self.emergeBtn.set_sensitive(False) self.unmergeBtn.set_sensitive(False) self.cancelBtn = gtk.Button("_Cancel") @@ -261,12 +270,6 @@ class PackageWindow (AbstractDialog): # show self.window.show_all() - def update_checkboxes (self): - """Updates the checkboxes.""" - self.installedCheck.set_active(self.actual_package().is_installed()) - self.maskedCheck.set_active(self.actual_package().is_masked()) - self.testingCheck.set_active((self.actual_package().get_mask_status() % 3) == 1) - def fill_use_list(self, store): pkg = self.actual_package() pkg_flags = pkg.get_all_use_flags() @@ -343,15 +346,38 @@ class PackageWindow (AbstractDialog): store.clear() self.fill_use_list(store) - self.update_checkboxes() + pkg = self.actual_package() - # set emerge-button-label - if not self.actual_package().is_installed(): - self.emergeBtn.set_label("_Emerge") - self.unmergeBtn.set_sensitive(False) + if pkg.is_missing_keyword(): + self.missing_label.show() + self.installedCheck.hide() + self.maskedCheck.hide() + self.testingCheck.hide() + self.emergeBtn.set_sensitive(False) else: - self.emergeBtn.set_label("R_emerge") - self.unmergeBtn.set_sensitive(True) + self.missing_label.hide() + self.installedCheck.show() + self.maskedCheck.show() + self.testingCheck.show() + if self.doEmerge: + self.emergeBtn.set_sensitive(True) + self.installedCheck.set_active(pkg.is_installed()) + self.maskedCheck.set_active(pkg.is_masked()) + if pkg.is_testing(allowed = False) and not pkg.is_testing(allowed=True): + self.testingCheck.set_label("<i>(Testing)</i>") + self.testingCheck.get_child().set_use_markup(True) + else: + self.testingCheck.set_label("Testing") + self.testingCheck.set_active(pkg.is_testing(allowed = False)) + + if self.doEmerge: + # set emerge-button-label + if not self.actual_package().is_installed(): + self.emergeBtn.set_label("_Emerge") + self.unmergeBtn.set_sensitive(False) + else: + self.emergeBtn.set_label("R_emerge") + self.unmergeBtn.set_sensitive(True) # refresh - make window as small as possible self.table.show_all() @@ -368,6 +394,7 @@ class PackageWindow (AbstractDialog): if self.delOnClose: self.actual_package().remove_new_use_flags() self.actual_package().remove_new_masked() + self.actual_package().remove_new_testing() elif self.flagChanged: if self.queue: self.queue.append(self.actual_package().get_cpv(), update = True) @@ -399,9 +426,27 @@ class PackageWindow (AbstractDialog): self.window.destroy() return True + def cb_testing_toggled (self, button): + status = button.get_active() + + if self.actual_package().is_testing(allowed = False) == status: + return False + + if not self.actual_package().is_testing(allowed = True): + self.actual_package().set_testing(False) + button.set_label("Testing") + button.set_active(True) + else: + self.actual_package().set_testing(True) + if self.actual_package().is_testing(allowed=False): + button.set_label("<i>(Testing)</i>") + button.get_child().set_use_markup(True) + button.set_active(True) + self.flagChanged = True + return True + def cb_masked_toggled (self, button): status = button.get_active() - debug("status: ",status) self.actual_package().set_masked(status) self.flagChanged = True return True diff --git a/obsolete/geneticthread.c b/obsolete/geneticthread.c deleted file mode 100644 index 33520a6..0000000 --- a/obsolete/geneticthread.c +++ /dev/null @@ -1,62 +0,0 @@ -/* - * This is a python module implementing real threads. - */ -#include <Python.h> -#include <pthread.h> - -/** - * Callback for the thread. Just calls the argument's python function. - */ -static void * thread_cb (void * arg) -{ - PyObject * arglist; - - arglist = Py_BuildValue("()",NULL); - PyEval_CallObject((PyObject*)arg, arglist); - Py_DECREF(arglist); - Py_DECREF((PyObject*)arg); - - return NULL; -} - -/** - * Function called from the python application. - */ -static PyObject * thread_start (PyObject * self, PyObject *args) -{ - PyObject *temp; - pthread_t ID; - - if (PyArg_ParseTuple(args, "O:thread_start", &temp)) // get argument - { - if (!PyCallable_Check(temp)) // not callable - { - PyErr_SetString(PyExc_TypeError, "parameter must be callable"); - return NULL; - } - Py_INCREF(temp); /* Add a reference to new callback */ - int status = pthread_create(&ID, NULL, thread_cb, (void*) temp); - if (status) - { - PyErr_SetString(PyExc_SystemError, "error during thread start"); - return NULL; - } - } - - Py_RETURN_NONE; -} - -static PyMethodDef ThreadMethods[] = { - {"thread_start", thread_start, METH_VARARGS, - "Start a new thread."}, - {NULL, NULL, 0, NULL} /* Sentinel */ -}; - -/** - * Init function. - */ -PyMODINIT_FUNC -initgeneticthread(void) -{ - (void) Py_InitModule("geneticthread", ThreadMethods); -} diff --git a/obsolete/helper.py b/obsolete/helper.py deleted file mode 100644 index ce5618a..0000000 --- a/obsolete/helper.py +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/python - -from geneticone import helper - -"""Some obsolete functions from geneticone.helper.""" - -def old_export_to_dictionaries (list_of_packages): - '''DEPRECATED: - Exports some of the intrinsic data of a list of Package objects to a list of dictionaries. - This is meant to transmit data back to the genetic-client, just by eval()-uating the output.''' - dictionaries=[] - keys=['name','version','category','cpv','runtime_deps','compiletime_deps','postmerge_deps','is_installed', 'is_overlay', 'is_masked','mask_status', 'package_path', 'size','use_flags_when_installed','all_useflags','set_useflags'] - package_methods=['get_name','get_version','get_category','get_cpv','get_runtime_deps', 'get_compiletime_deps','get_postmerge_deps','is_installed','is_overlay','is_masked','get_mask_status','get_package_path','size','get_use_flags','get_all_useflags','get_set_useflags'] - - for item in list_of_packages: - dictionaries.append({}) - for key,method in zip(keys,package_methods): - try: - dictionaries[-1][key]=eval('item.'+method+'()') - except AttributeError: #this may happen if, for example, package is not installed and I look for the path... - dictionaries[-1][key]=None - return dictionaries - -def export_to_dictionaries (packages): - '''Exports some of the intrinsic data of a list of Package objects to a list of dictionaries. - This is meant to transmit data back to the genetic-client, just by eval()-uating the output.''' - dictionaries=[] - - for item in packages: - dictionaries.append({}) - for method in dir(item): - if (method.startswith('get_') or method.startswith('is_'))\ - and method != 'get_dependants': # bug in gentoolkit.Package.get_dependants --> see bug #137783 - key = method[method.index('_')+1:] # the key is everything after the first underscore - try: - dictionaries[-1][key] = eval("item."+method+"()") - except AttributeError: # this may happen if, for example, package is not installed and I look for the path... - dictionaries[-1][key] = None - except TypeError: - pass # this method takes an argument - ignore it - except NotImplementedError: - pass # this method is not implemented - ignore - except "Not implemented yet!": - pass - return dictionaries |