Back to index

system-config-printer  1.3.9+20120706
ErrorLogParse.py
Go to the documentation of this file.
00001 #!/usr/bin/python
00002 
00003 ## Printing troubleshooter
00004 
00005 ## Copyright (C) 2008 Red Hat, Inc.
00006 ## Copyright (C) 2008 Tim Waugh <twaugh@redhat.com>
00007 
00008 ## This program is free software; you can redistribute it and/or modify
00009 ## it under the terms of the GNU General Public License as published by
00010 ## the Free Software Foundation; either version 2 of the License, or
00011 ## (at your option) any later version.
00012 
00013 ## This program is distributed in the hope that it will be useful,
00014 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 ## GNU General Public License for more details.
00017 
00018 ## You should have received a copy of the GNU General Public License
00019 ## along with this program; if not, write to the Free Software
00020 ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00021 
00022 from base import *
00023 class ErrorLogParse(Question):
00024 
00025     ## This could be a LOT smarter.
00026 
00027     def __init__ (self, troubleshooter):
00028         Question.__init__ (self, troubleshooter, "Error log parse")
00029         page = self.initial_vbox (_("Error log messages"),
00030                                   _("There are messages in the error log."))
00031         sw = gtk.ScrolledWindow ()
00032         textview = gtk.TextView ()
00033         textview.set_editable (False)
00034         sw.add (textview)
00035         page.pack_start (sw)
00036         self.buffer = textview.get_buffer ()
00037         troubleshooter.new_page (page, self)
00038 
00039     def display (self):
00040         answers = self.troubleshooter.answers
00041         try:
00042             error_log = answers['error_log']
00043         except KeyError:
00044             return False
00045 
00046         display = False
00047         for line in error_log:
00048             if line[0] == 'E':
00049                 display = True
00050                 break
00051 
00052         if display:
00053             self.buffer.set_text (reduce (lambda x, y: x + '\n' + y, 
00054                                           error_log))
00055 
00056         return display