From 44a726cd69e3e0d5c50890946b366c441a575a37 Mon Sep 17 00:00:00 2001
From: necoro <>
Date: Sat, 21 Jul 2007 22:13:06 +0000
Subject: added logviewers
---
portato/gui/gtk/windows.py | 51 +++-
portato/gui/qt/windows.py | 30 ++-
portato/gui/templates/portato.glade | 429 ++++++++++++++++++---------------
portato/gui/templates/ui/LogDialog.ui | 88 +++++++
portato/gui/templates/ui/MainWindow.ui | 22 +-
portato/plugin.py | 9 +-
6 files changed, 419 insertions(+), 210 deletions(-)
create mode 100644 portato/gui/templates/ui/LogDialog.ui
(limited to 'portato')
diff --git a/portato/gui/gtk/windows.py b/portato/gui/gtk/windows.py
index 51179c3..33cd037 100644
--- a/portato/gui/gtk/windows.py
+++ b/portato/gui/gtk/windows.py
@@ -33,7 +33,7 @@ from wrapper import GtkTree, GtkConsole
from usetips import UseTips
# other
-import types
+import types, logging
GLADE_FILE = DATA_DIR+"portato.glade"
@@ -832,6 +832,44 @@ class PackageTable:
return True
+class LogWindow (AbstractDialog, logging.Handler):
+
+ def __init__ (self, parent):
+ AbstractDialog.__init__(self, parent)
+ logging.Handler.__init__(self, logging.INFO)
+
+ self.logView = self.tree.get_widget("logView")
+ logging.getLogger("portatoLogger").addHandler(self)
+
+ self.deleteIsOk = False
+
+ def format (self, record):
+
+ if (record.levelno > logging.INFO):
+ return "%s: %s" % (record.levelname, record.getMessage())
+ else:
+ return record.getMessage()
+
+ def emit (self, record):
+ self.logView.get_buffer().insert_at_cursor(self.format(record)+"\n")
+
+ def show (self):
+ self.window.show()
+
+ def close (self):
+ self.window.hide()
+
+ def destroy (self):
+ self.deleteIsOk = True
+ self.window.destroy()
+
+ def cb_delete (self, *args):
+ if not self.deleteIsOk:
+ self.close()
+ return True
+ else:
+ return False
+
class MainWindow (Window):
"""Application main window."""
@@ -852,13 +890,16 @@ class MainWindow (Window):
mHeight = 800
if gtk.gdk.screen_height() <= 800: mHeight = 600
self.window.set_geometry_hints (self.window, min_width = 600, min_height = mHeight, max_height = gtk.gdk.screen_height(), max_width = gtk.gdk.screen_width())
-
+
# booleans
self.doUpdate = False
# installed pixbuf
self.instPixbuf = self.window.render_icon(gtk.STOCK_YES, gtk.ICON_SIZE_MENU)
+ # get the logging window as soon as possible
+ self.logWindow = LogWindow(self.window)
+
# package db
self.db = Database()
self.db.populate()
@@ -1232,7 +1273,10 @@ class MainWindow (Window):
PluginWindow(self.window, queue)
return True
-
+
+ def cb_show_log_clicked (self, btn):
+ self.logWindow.show()
+
@Window.watch_cursor
def cb_show_updates_clicked (self, button):
UpdateWindow(self.window, system.get_updated_packages(), self.queue, self.jump_to)
@@ -1322,6 +1366,7 @@ class MainWindow (Window):
def cb_destroy (self, widget):
"""Calls main_quit()."""
+ self.logWindow.destroy()
gtk.main_quit()
def main (self):
diff --git a/portato/gui/qt/windows.py b/portato/gui/qt/windows.py
index 5aa0e24..ba4dcc5 100644
--- a/portato/gui/qt/windows.py
+++ b/portato/gui/qt/windows.py
@@ -32,7 +32,7 @@ from highlighter import EbuildHighlighter
from dialogs import *
from helper import qCheck, qIsChecked
-import types
+import types, logging
UI_DIR = DATA_DIR+"ui/"
@@ -252,6 +252,27 @@ class EbuildDialog (Window):
self.doc.setPlainText("".join(lines))
self.ebuildEdit.setDocument(self.doc)
+class LogDialog (Window, logging.Handler):
+
+ __metaclass__ = WindowMeta
+
+ def __init__ (self, parent):
+ Window.__init__(self, parent)
+
+ self.setAttribute(Qt.Qt.WA_DeleteOnClose, False)
+ logging.Handler.__init__(self, logging.INFO)
+ logging.getLogger("portatoLogger").addHandler(self)
+
+ def format (self, record):
+
+ if (record.levelno > logging.INFO):
+ return "%s: %s" % (record.levelname, record.getMessage())
+ else:
+ return record.getMessage()
+
+ def emit (self, record):
+ self.logView.insertPlainText(self.format(record)+"\n")
+
class PreferenceWindow (Window):
"""Window displaying some preferences."""
@@ -707,6 +728,9 @@ class MainWindow (Window):
self.doUpdate = False
self.pkgDetails = PackageDetails(self)
+ # set the logger as early as possible
+ self.logDialog = LogDialog(self)
+
# package db
self.db = Database()
self.db.populate()
@@ -842,6 +866,10 @@ class MainWindow (Window):
else:
self.systray = None
+ @Qt.pyqtSignature("")
+ def on_logAction_triggered (self):
+ self.logDialog.show()
+
@Qt.pyqtSignature("")
def on_aboutAction_triggered (self):
AboutDialog(self).exec_()
diff --git a/portato/gui/templates/portato.glade b/portato/gui/templates/portato.glade
index 9238f51..b28591c 100644
--- a/portato/gui/templates/portato.glade
+++ b/portato/gui/templates/portato.glade
@@ -328,6 +328,15 @@
+
+
+
@@ -442,52 +451,74 @@
4
2
-
+
True
- 1
- True
-
-
- True
- True
- Installed
- 0
- True
-
-
-
- False
-
-
+ False
+ GTK_POLICY_AUTOMATIC
+ GTK_POLICY_AUTOMATIC
-
+
True
- True
- Masked
- 0
- True
-
-
- False
- 1
-
+
+
+ 2
+ 2
+ 3
+ 5
+ 5
+
+
+
+
+ True
-
- 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
2
@@ -555,80 +586,58 @@
-
- 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
+
-
-
- 1
- 2
- GTK_FILL
- 5
-
-
-
-
- True
- False
- GTK_POLICY_AUTOMATIC
- GTK_POLICY_AUTOMATIC
-
+
+ True
+ True
+ Masked
+ 0
+ True
+
+
+
+ False
+ 1
+
+
+
+
True
+ True
+ Testing
+ 0
+ True
+
+
+ False
+ 2
+
+ 1
2
- 2
- 3
- 5
- 5
+ 1
+ 2
+ GTK_FILL
@@ -1003,189 +1012,189 @@
-
- True
- 0
- 5
- <u><i>Masking Keywords</i></u>
- True
- True
-
-
- 7
- 8
- 5
-
-
-
-
+
True
- 0
- 5
- <u><i>Testing Keywords</i></u>
- True
- True
- 4
- 5
- 5
+ 1
+ 2
+ 3
+ 4
-
+
True
0
- 5
- <u><i>Use-Flags</i></u>
- True
+ File name to use, if package.use is a directory:
True
- 1
- 2
- 6
+ 3
+ 4
-
+
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
- Add only exact version to package.mask/package.unmask
+ Add only exact version to package.keywords
0
True
2
- 8
- 9
+ 5
+ 6
-
+
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
1
2
- 9
- 10
+ 6
+ 7
-
+
True
1
2
- 6
- 7
+ 9
+ 10
-
+
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
- Add only exact version to package.keywords
+ Add only exact version to package.mask/package.unmask
0
True
2
- 5
- 6
+ 8
+ 9
-
+
True
- Add only exact version to package.use
- 0
- 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
0
- File name to use, if package.use is a directory:
+ 5
+ <u><i>Use-Flags</i></u>
+ True
True
- 3
- 4
+ 1
+ 2
+ 6
-
+
True
+ 0
+ 5
+ <u><i>Testing Keywords</i></u>
+ True
+ True
- 1
- 2
- 3
- 4
+ 4
+ 5
+ 5
+
+
+
+
+ True
+ 0
+ 5
+ <u><i>Masking Keywords</i></u>
+ True
+ True
+
+
+ 7
+ 8
+ 5
@@ -1607,4 +1616,32 @@ uses code from: Daniel J. Popowich
+
+ GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
+ Logging Output
+ GTK_WIN_POS_CENTER_ON_PARENT
+ 400
+ 500
+ True
+ True
+
+
+
+ True
+ True
+ GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
+ GTK_POLICY_AUTOMATIC
+ GTK_POLICY_AUTOMATIC
+
+
+ True
+ True
+ GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
+ False
+ False
+
+
+
+
+
diff --git a/portato/gui/templates/ui/LogDialog.ui b/portato/gui/templates/ui/LogDialog.ui
new file mode 100644
index 0000000..3415893
--- /dev/null
+++ b/portato/gui/templates/ui/LogDialog.ui
@@ -0,0 +1,88 @@
+
+ LogDialog
+
+
+
+ 0
+ 0
+ 481
+ 603
+
+
+
+ Log Viewer
+
+
+
+ 9
+
+
+ 6
+
+ -
+
+
+ false
+
+
+ true
+
+
+ false
+
+
+ 0
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+ QDialogButtonBox::Ok
+
+
+ true
+
+
+
+
+
+
+
+
+ buttonBox
+ accepted()
+ LogDialog
+ accept()
+
+
+ 248
+ 254
+
+
+ 157
+ 274
+
+
+
+
+ buttonBox
+ rejected()
+ LogDialog
+ reject()
+
+
+ 316
+ 260
+
+
+ 286
+ 274
+
+
+
+
+
diff --git a/portato/gui/templates/ui/MainWindow.ui b/portato/gui/templates/ui/MainWindow.ui
index 5329f9e..0011ead 100644
--- a/portato/gui/templates/ui/MainWindow.ui
+++ b/portato/gui/templates/ui/MainWindow.ui
@@ -428,13 +428,6 @@ p, li { white-space: pre-wrap; }
-
+
@@ -544,7 +545,7 @@ p, li { white-space: pre-wrap; }
- Plugins
+ &Plugins
@@ -555,6 +556,11 @@ p, li { white-space: pre-wrap; }
Emerge &paused
+
+
+ Show &Logs
+
+
diff --git a/portato/plugin.py b/portato/plugin.py
index 1aa521a..ea11c3a 100644
--- a/portato/plugin.py
+++ b/portato/plugin.py
@@ -349,8 +349,13 @@ class PluginQueue:
for p in plugins:
- if not schema.validate(etree.parse(p)):
- error("Loading plugin '%s' failed. Plugin does not comply to schema.", p)
+ try:
+ schema.assertValid(etree.parse(p))
+ except etree.XMLSyntaxError:
+ error("Loading plugin '%s' failed. Invalid XML syntax.", p)
+ continue
+ except etree.DocumentInvalid:
+ error("Loading plugin '%s' failed. Plugin does not comply with schema.", p)
continue
doc = parse(p)
--
cgit v1.2.3