From b5e8e2eb2b8bc9936070028ecf91ff8d0b7c33ef Mon Sep 17 00:00:00 2001 From: necoro <> Date: Wed, 11 Jul 2007 07:37:22 +0000 Subject: added SIGSTOP/SIGCONT support; SIGTERM now works ;) --- doc/TODO | 6 +- portato/gui/gtk/windows.py | 8 + portato/gui/gui_helper.py | 14 +- portato/gui/qt/terminal.py | 2 + portato/gui/qt/windows.py | 11 + portato/gui/templates/portato.glade | 403 +++++++++++++++++---------------- portato/gui/templates/ui/MainWindow.ui | 23 +- portato/helper.py | 16 ++ 8 files changed, 275 insertions(+), 208 deletions(-) diff --git a/doc/TODO b/doc/TODO index c46e90c..d0f9b6e 100644 --- a/doc/TODO +++ b/doc/TODO @@ -1,13 +1,15 @@ Documentation: ============== -- document the structure of plugin-XMLs - Backend: ======== +- add Paludis support + - bugs in update world (Necoro, 04/20/07: are there any more bugs?) - fix for flag handling, when reverting flags (Necoro, 04/20/07: what did i mean by this?) + ==> rewrite flags handling in an object oriented manner + - do not alert a block, if a package blocks a version of one package which is updated to a new one not being blocked anymore - save/restore queue on exit/start diff --git a/portato/gui/gtk/windows.py b/portato/gui/gtk/windows.py index 8b433ca..6eacd34 100644 --- a/portato/gui/gtk/windows.py +++ b/portato/gui/gtk/windows.py @@ -1273,6 +1273,14 @@ class MainWindow (Window): self.cfg.set_local(package, "oneshot", set) self.queue.append(package, update = True, oneshot = set, forceUpdate = True) + def cb_stop_cont_toggled (self, cb): + if not cb.get_active(): + self.queue.continue_emerge() + else: + self.queue.stop_emerge() + + return False + def cb_kill_clicked (self, action): self.queue.kill_emerge() diff --git a/portato/gui/gui_helper.py b/portato/gui/gui_helper.py index 358f56e..8ee858f 100644 --- a/portato/gui/gui_helper.py +++ b/portato/gui/gui_helper.py @@ -624,9 +624,8 @@ class EmergeQueue: """Kills the emerge process.""" if self.process is not None: try: - os.kill(self.process.pid, signal.SIGTERM) + send_signal_to_group(signal.SIGTERM) debug("Process should be killed") - os.kill(self.process.pid, signal.SIGKILL) # to be sure except AttributeError: debug("AttributeError occured ==> process not exisiting - ignore") except OSError: @@ -634,6 +633,17 @@ class EmergeQueue: self.process = None + def stop_emerge (self): + if self.process is not None: + # use SIGTSTP in favor of SIGSTOP, as SIGSTOP cannot be blocked and would stop the GUI too + send_signal_to_group(signal.SIGTSTP) + debug("Process should be stopped") + + def continue_emerge (self): + if self.process is not None: + send_signal_to_group(signal.SIGCONT) + debug("Process should continue") + def remove_with_children (self, it, removeNewFlags = True): """Convenience function which removes all children of an iterator and than the iterator itself. diff --git a/portato/gui/qt/terminal.py b/portato/gui/qt/terminal.py index 23e090a..0c7cf8b 100644 --- a/portato/gui/qt/terminal.py +++ b/portato/gui/qt/terminal.py @@ -118,6 +118,8 @@ class QtConsole (Console, Qt.QTextEdit): self.writeQueue = "" self.isNotWrapping = False + self.setContextMenuPolicy(Qt.Qt.ActionsContextMenu) + # set black bg self.palette().setColor(Qt.QPalette.Base, Qt.QColor("black")) diff --git a/portato/gui/qt/windows.py b/portato/gui/qt/windows.py index 5f1100f..a61a6d7 100644 --- a/portato/gui/qt/windows.py +++ b/portato/gui/qt/windows.py @@ -742,6 +742,10 @@ class MainWindow (Window): self.consoleLayout.setSpacing(0) self.consoleTab.setLayout(self.consoleLayout) self.consoleLayout.addWidget(self.console) + + self.console.addAction(self.killAction) + self.console.addAction(self.pauseAction) + Qt.QObject.connect(self, Qt.SIGNAL("doTitleUpdate"), self._title_update) # build queueList @@ -863,6 +867,13 @@ class MainWindow (Window): self.db = Database() self.db.populate() + @Qt.pyqtSignature("bool") + def on_pauseAction_triggered (self, checked): + if checked: + self.queue.stop_emerge() + else: + self.queue.continue_emerge() + @Qt.pyqtSignature("") def on_killAction_triggered (self): self.queue.kill_emerge() diff --git a/portato/gui/templates/portato.glade b/portato/gui/templates/portato.glade index ffb63f1..9238f51 100644 --- a/portato/gui/templates/portato.glade +++ b/portato/gui/templates/portato.glade @@ -132,7 +132,7 @@ True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - Show Updatable _Packages + Show Updatable P_ackages True @@ -262,6 +262,15 @@ + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Emerge _Paused + True + + + @@ -433,73 +442,51 @@ 4 2 - + True - False - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC + 1 + True - + True + True + Installed + 0 + True + + + False + - - - 2 - 2 - 3 - 5 - 5 - - - - - True - + + True + True + Masked + 0 + True + + + + False + 1 + + + + + True + True + Testing + 0 + True + + + + False + 2 + - - - 1 - 2 - GTK_FILL - 5 - - - - - True - GTK_JUSTIFY_CENTER - True - - - 2 - GTK_FILL - - 10 - - - - - True - True - <span foreground='red'><b>MISSING KEYWORD</b></span> - True - - - 1 - 2 - 1 - 2 - GTK_FILL - - - - - True - True - <b>Installed, but not in portage anymore</b> - True 1 @@ -568,58 +555,80 @@ - + + True + True + <b>Installed, but not in portage anymore</b> + True + + + 1 + 2 + 1 + 2 + GTK_FILL + + + + + True + True + <span foreground='red'><b>MISSING KEYWORD</b></span> + True + + + 1 + 2 + 1 + 2 + GTK_FILL + + + + + True + GTK_JUSTIFY_CENTER + True + + + 2 + GTK_FILL + + 10 + + + + True - 1 - True - - - True - True - Installed - 0 - True - - - - False - - - - True - True - Masked - 0 - True - - - - False - 1 - + + + + 1 + 2 + GTK_FILL + 5 + + + + + True + False + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC - + True - True - Testing - 0 - True - - - False - 2 - - 1 2 - 1 - 2 - GTK_FILL + 2 + 3 + 5 + 5 @@ -994,189 +1003,189 @@ - + True + 0 + 5 + <u><i>Masking Keywords</i></u> + True + True - 1 - 2 - 3 - 4 + 7 + 8 + 5 - + True 0 - File name to use, if package.use is a directory: + 5 + <u><i>Testing Keywords</i></u> + True True - 3 - 4 + 4 + 5 + 5 - + True - Add only exact version to package.use - 0 - True + 0 + 5 + <u><i>Use-Flags</i></u> + True + True + + + 1 + 2 + 6 + + + + + True + + + True + 0 + GTK_SHADOW_OUT + + + True + 0 + <u>You may use the following placeholders:</u> + +<i>$(cat)</i>: category +<i>$(pkg)</i>: package name +<i>$(cat-1)/$(cat-2)</i>: first/second part of the category + True + + + + + + label_item + + + + 2 - 2 - 3 - + True - Add only exact version to package.keywords + Add only exact version to package.mask/package.unmask 0 True 2 - 5 - 6 + 8 + 9 - + True 0 - File name to use, if package.keywords is a directory: + File name to use, if package.mask/package.unmask is a directory: True - 6 - 7 + 9 + 10 - + True 1 2 - 6 - 7 + 9 + 10 - + True 1 2 - 9 - 10 + 6 + 7 - + True 0 - File name to use, if package.mask/package.unmask is a directory: + File name to use, if package.keywords is a directory: True - 9 - 10 + 6 + 7 - + True - Add only exact version to package.mask/package.unmask + Add only exact version to package.keywords 0 True 2 - 8 - 9 + 5 + 6 - + True - - - True - 0 - GTK_SHADOW_OUT - - - True - 0 - <u>You may use the following placeholders:</u> - -<i>$(cat)</i>: category -<i>$(pkg)</i>: package name -<i>$(cat-1)/$(cat-2)</i>: first/second part of the category - True - - - - - - label_item - - - - + Add only exact version to package.use + 0 + True 2 + 2 + 3 - - True - 0 - 5 - <u><i>Use-Flags</i></u> - True - True - - - 1 - 2 - 6 - - - - + True 0 - 5 - <u><i>Testing Keywords</i></u> - True + File name to use, if package.use is a directory: True - 4 - 5 - 5 + 3 + 4 - + True - 0 - 5 - <u><i>Masking Keywords</i></u> - True - True - 7 - 8 - 5 + 1 + 2 + 3 + 4 diff --git a/portato/gui/templates/ui/MainWindow.ui b/portato/gui/templates/ui/MainWindow.ui index 9a3e15e..5329f9e 100644 --- a/portato/gui/templates/ui/MainWindow.ui +++ b/portato/gui/templates/ui/MainWindow.ui @@ -428,6 +428,13 @@ p, li { white-space: pre-wrap; } + + + &? + + + + &Emerge @@ -441,13 +448,7 @@ p, li { white-space: pre-wrap; } - - - - &? - - - + @@ -546,6 +547,14 @@ p, li { white-space: pre-wrap; } Plugins + + + true + + + Emerge &paused + + diff --git a/portato/helper.py b/portato/helper.py index 9328223..cc797b9 100644 --- a/portato/helper.py +++ b/portato/helper.py @@ -18,6 +18,7 @@ Some nice functions used in the program. """ import traceback, os.path, sys, types +import os, signal DEBUG = True @@ -80,6 +81,21 @@ def debug(*args, **kwargs): else: print >> outfile, text +def send_signal_to_group (sig): + """Sends a signal to all processes of our process group (w/o ourselves). + + @param sig: signal number to send + @type sig: int""" + + def handler (sig, stack): + """Ignores the signal exactly one time and then restores the default.""" + signal.signal(sig, signal.SIG_DFL) + + signal.signal(sig, handler) + + pgid = os.getpgrp() + os.killpg(pgid, sig) + def am_i_root (): """Returns True if the current user is root, False otherwise. @rtype: boolean""" -- cgit v1.2.3