From 2a8dfdad5a5e4ccb0c7a2e9147c38336ba76d733 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 14 Jan 2010 17:47:01 +0100 Subject: gui: add logging infrastructure Signed-off-by: Denys Vlasenko --- src/Gui/CCMainWindow.py | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'src/Gui/CCMainWindow.py') diff --git a/src/Gui/CCMainWindow.py b/src/Gui/CCMainWindow.py index f4e3a73..432fd43 100644 --- a/src/Gui/CCMainWindow.py +++ b/src/Gui/CCMainWindow.py @@ -2,6 +2,7 @@ import sys import os import pwd +import getopt import pygtk pygtk.require("2.0") import gobject @@ -12,6 +13,11 @@ except RuntimeError,e: print e os.exit() import gtk.glade +try: + import rpm +except Exception, ex: + rpm = None + import CCDBusBackend from CC_gui_functions import * from CCDumpList import getDumpList, DumpList @@ -21,12 +27,7 @@ from SettingsDialog import SettingsDialog from CCReport import Report from PluginList import getPluginInfoList import ABRTExceptions -from abrt_utils import _ - -try: - import rpm -except Exception, ex: - rpm = None +from abrt_utils import _, init_logging, log, log1, log2 class MainWindow(): @@ -381,8 +382,19 @@ class MainWindow(): self.window.present() if __name__ == "__main__": + try: + opts, args = getopt.getopt(sys.argv[1:], "v") + except getopt.GetoptError, err: + print str(err) # prints something like "option -a not recognized" + sys.exit(2) + verbose = 0 + for opt, arg in opts: + if opt == "-v": + verbose += 1 + init_logging("abrt-gui", verbose) + log1("log level:%d", verbose) + cc = MainWindow() cc.hydrate() cc.show() gtk.main() - -- cgit From 1ff447ffaaa02cd0c46607f817c13328114145bc Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 14 Jan 2010 23:06:00 +0100 Subject: add code to make GUI -> daemon settings passing less weird. not enabled yet Signed-off-by: Denys Vlasenko --- src/Gui/CCMainWindow.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/Gui/CCMainWindow.py') diff --git a/src/Gui/CCMainWindow.py b/src/Gui/CCMainWindow.py index 432fd43..0bc00e5 100644 --- a/src/Gui/CCMainWindow.py +++ b/src/Gui/CCMainWindow.py @@ -18,6 +18,7 @@ try: except Exception, ex: rpm = None +from ConfBackend import ConfBackendGnomeKeyring, ConfBackendInitError import CCDBusBackend from CC_gui_functions import * from CCDumpList import getDumpList, DumpList @@ -42,11 +43,10 @@ class MainWindow(): sys.exit() except Exception, e: # show error message if connection fails - # FIXME add an option to start the daemon gui_error_message("%s" % e) sys.exit() #Set the Glade file - self.gladefile = "%s%sccgui.glade" % (sys.path[0],"/") + self.gladefile = "%s/ccgui.glade" % sys.path[0] self.wTree = gtk.glade.XML(self.gladefile) #Get the Main Window, and connect the "destroy" event @@ -304,6 +304,10 @@ class MainWindow(): self.pluginlist = getPluginInfoList(self.ccdaemon) for plugin in self.pluginlist.getReporterPlugins(): reporters_settings[str(plugin)] = plugin.Settings + # TODO: this way, we don't need to talk to daemon in order to get + # all plugin settings: + #reporters_settings2 = ConfBackendGnomeKeyring().load_all() + #log1("reporters_settings2:%s", str(reporters_settings2)) self.ccdaemon.Report(result, reporters_settings) #self.hydrate() except Exception, e: -- cgit From 494ed25390a3c1fa831ca594b77135eb5f18fba8 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 15 Jan 2010 16:04:27 +0100 Subject: GUI: better code for plugin settings overriding; better logging; fixed "not reported" display bug Signed-off-by: Denys Vlasenko --- src/Gui/CCMainWindow.py | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) (limited to 'src/Gui/CCMainWindow.py') diff --git a/src/Gui/CCMainWindow.py b/src/Gui/CCMainWindow.py index 0bc00e5..5ffc027 100644 --- a/src/Gui/CCMainWindow.py +++ b/src/Gui/CCMainWindow.py @@ -18,7 +18,7 @@ try: except Exception, ex: rpm = None -from ConfBackend import ConfBackendGnomeKeyring, ConfBackendInitError +from ConfBackend import getCurrentConfBackend, ConfBackendInitError import CCDBusBackend from CC_gui_functions import * from CCDumpList import getDumpList, DumpList @@ -234,9 +234,11 @@ class MainWindow(): # it is not informative (no URL to the report) for message in dump.getMessage().split('\n'): if message: - if "http" in message[0:5] or "file:///"[0:8] in message: - message = "%s" % (message, message) + #Doesn't work (far too easy to make it worse, not better): + #if "http" in message[0:5] or "file:///"[0:8] in message: + # message = "%s" % (message, message) report_label += "%s\n" % message + log2("setting markup '%s'", report_label) self.wTree.get_widget("lReported").set_markup(report_label) else: self.wTree.get_widget("lReported").set_markup(_("Not reported!")) @@ -298,17 +300,20 @@ class MainWindow(): try: self.pBarWindow.show_all() self.timer = gobject.timeout_add(100, self.progress_update_cb) - reporters_settings = {} - # self.pluginlist = getPluginInfoList(self.ccdaemon, refresh=True) - # don't force refresh! - self.pluginlist = getPluginInfoList(self.ccdaemon) - for plugin in self.pluginlist.getReporterPlugins(): - reporters_settings[str(plugin)] = plugin.Settings - # TODO: this way, we don't need to talk to daemon in order to get - # all plugin settings: - #reporters_settings2 = ConfBackendGnomeKeyring().load_all() - #log1("reporters_settings2:%s", str(reporters_settings2)) + # Old way: it needs to talk to daemon + #reporters_settings = {} + ## self.pluginlist = getPluginInfoList(self.ccdaemon, refresh=True) + ## don't force refresh! + #self.pluginlist = getPluginInfoList(self.ccdaemon) + #for plugin in self.pluginlist.getReporterPlugins(): + # reporters_settings[str(plugin)] = plugin.Settings + reporters_settings = getCurrentConfBackend().load_all() + log2("Report(result,settings):") + log2(" result:%s", str(result)) + # Careful, this will print reporters_settings["Password"] too + log2(" settings:%s", str(reporters_settings)) self.ccdaemon.Report(result, reporters_settings) + log2("Report() returned") #self.hydrate() except Exception, e: gui_error_message(_("Reporting failed!\n%s" % e)) -- cgit From f595a339a65cf59b45a9f4c853cac456ff81c467 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 18 Jan 2010 13:45:59 +0100 Subject: s/os.exit/sys.exit - closes rhbz#556313 Signed-off-by: Denys Vlasenko --- src/Gui/CCMainWindow.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Gui/CCMainWindow.py') diff --git a/src/Gui/CCMainWindow.py b/src/Gui/CCMainWindow.py index 5ffc027..dcb71ae 100644 --- a/src/Gui/CCMainWindow.py +++ b/src/Gui/CCMainWindow.py @@ -11,7 +11,7 @@ try: except RuntimeError,e: # rhbz#552039 print e - os.exit() + sys.exit() import gtk.glade try: import rpm -- cgit