Back to index

system-config-printer  1.3.9+20120706
Public Member Functions | Public Attributes
troubleshoot.ErrorLogFetch.ErrorLogFetch Class Reference
Inheritance diagram for troubleshoot.ErrorLogFetch.ErrorLogFetch:
Inheritance graph
[legend]
Collaboration diagram for troubleshoot.ErrorLogFetch.ErrorLogFetch:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def display
def collect_answer
def cancel_operation
def connect_signals
def disconnect_signals
def can_click_forward
def initial_vbox
 Helper functions.

Public Attributes

 persistent_answers
 answers
 authconn
 op
 troubleshooter

Detailed Description

Definition at line 29 of file ErrorLogFetch.py.


Constructor & Destructor Documentation

def troubleshoot.ErrorLogFetch.ErrorLogFetch.__init__ (   self,
  troubleshooter 
)

Definition at line 30 of file ErrorLogFetch.py.

00030 
00031     def __init__ (self, troubleshooter):
00032         Question.__init__ (self, troubleshooter, "Error log fetch")
00033         troubleshooter.new_page (gtk.Label (), self)
00034         self.persistent_answers = {}


Member Function Documentation

Reimplemented from troubleshoot.base.Question.

Definition at line 125 of file ErrorLogFetch.py.

00125 
00126     def cancel_operation (self):
00127         self.op.cancel ()
00128 
00129         # Abandon the CUPS connection and make another.
00130         answers = self.troubleshooter.answers
00131         factory = answers['_authenticated_connection_factory']
00132         self.authconn = factory.get_connection ()
00133         self.answers['_authenticated_connection'] = self.authconn

Reimplemented from troubleshoot.base.Question.

Definition at line 120 of file ErrorLogFetch.py.

00120 
00121     def collect_answer (self):
00122         answers = self.persistent_answers.copy ()
00123         answers.update (self.answers)
00124         return answers

def troubleshoot.base.Question.connect_signals (   self,
  handler 
) [inherited]
Returns True if this page should be displayed, or False
if it should be skipped.

Reimplemented from troubleshoot.base.Question.

Definition at line 35 of file ErrorLogFetch.py.

00035 
00036     def display (self):
00037         answers = self.troubleshooter.answers
00038         parent = self.troubleshooter.get_window ()
00039         self.answers = {}
00040         try:
00041             checkpoint = answers['error_log_checkpoint']
00042         except KeyError:
00043             checkpoint = None
00044 
00045         if self.persistent_answers.has_key ('error_log'):
00046             checkpoint = None
00047 
00048         def fetch_log (c):
00049             prompt = c._get_prompt_allowed ()
00050             c._set_prompt_allowed (False)
00051             c._connect ()
00052             (tmpfd, tmpfname) = tempfile.mkstemp ()
00053             os.close (tmpfd)
00054             success = False
00055             try:
00056                 c.getFile ('/admin/log/error_log', tmpfname)
00057                 success = True
00058             except cups.HTTPError:
00059                 try:
00060                     os.remove (tmpfname)
00061                 except OSError:
00062                     pass
00063 
00064             c._set_prompt_allowed (prompt)
00065             if success:
00066                 return tmpfname
00067             return None
00068 
00069         self.authconn = self.troubleshooter.answers['_authenticated_connection']
00070         if answers.has_key ('error_log_debug_logging_set'):
00071             try:
00072                 self.op = TimedOperation (self.authconn.adminGetServerSettings,
00073                                           parent=parent)
00074                 settings = self.op.run ()
00075             except cups.IPPError:
00076                 return False
00077 
00078             settings[cups.CUPS_SERVER_DEBUG_LOGGING] = '0'
00079             orig_settings = answers['cups_server_settings']
00080             settings['MaxLogSize'] = orig_settings.get ('MaxLogSize', '2000000')
00081             success = False
00082             def set_settings (connection, settings):
00083                 connection.adminSetServerSettings (settings)
00084 
00085                 # Now reconnect.
00086                 attempt = 1
00087                 while attempt <= 5:
00088                     try:
00089                         time.sleep (1)
00090                         connection._connect ()
00091                         break
00092                     except RuntimeError:
00093                         # Connection failed
00094                         attempt += 1
00095 
00096             try:
00097 
00098                 self.op = TimedOperation (set_settings,
00099                                           (self.authconn, settings),
00100                                           parent=parent)
00101                 self.op.run ()
00102                 self.persistent_answers['error_log_debug_logging_unset'] = True
00103             except cups.IPPError:
00104                 pass
00105 
00106         if checkpoint != None:
00107             self.op = TimedOperation (fetch_log,
00108                                       (self.authconn,),
00109                                       parent=parent)
00110             tmpfname = self.op.run ()
00111             if tmpfname != None:
00112                 f = file (tmpfname)
00113                 f.seek (checkpoint)
00114                 lines = f.readlines ()
00115                 os.remove (tmpfname)
00116                 self.answers = { 'error_log': map (lambda x: x.strip (),
00117                                                    lines) }
00118 
00119         return False

def troubleshoot.base.Question.initial_vbox (   self,
  title = '',
  text = '' 
) [inherited]

Helper functions.

Definition at line 66 of file base.py.

00066 
00067     def initial_vbox (self, title='', text=''):
00068         vbox = gtk.VBox ()
00069         vbox.set_border_width (12)
00070         vbox.set_spacing (12)
00071         if title:
00072             s = '<span weight="bold" size="larger">' + title + '</span>\n\n'
00073         else:
00074             s = ''
00075         s += text
00076         label = gtk.Label (s)
00077         label.set_alignment (0, 0)
00078         label.set_line_wrap (True)
00079         label.set_use_markup (True)
00080         vbox.pack_start (label, False, False, 0)
00081         return vbox

Here is the caller graph for this function:


Member Data Documentation

Definition at line 38 of file ErrorLogFetch.py.

Definition at line 68 of file ErrorLogFetch.py.

Definition at line 71 of file ErrorLogFetch.py.

Definition at line 33 of file ErrorLogFetch.py.

Reimplemented in troubleshoot.CheckPrinterSanity.CheckPrinterSanity.

Definition at line 41 of file base.py.


The documentation for this class was generated from the following file: