Back to index

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

List of all members.

Public Member Functions

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

Public Attributes

 button
 label
 persistent_answers
 answers
 authconn
 op
 forward_allowed
 button_sigid
 troubleshooter

Detailed Description

Definition at line 28 of file ErrorLogCheckpoint.py.


Constructor & Destructor Documentation

Definition at line 29 of file ErrorLogCheckpoint.py.

00029 
00030     def __init__ (self, troubleshooter):
00031         Question.__init__ (self, troubleshooter, "Error log checkpoint")
00032         page = self.initial_vbox (_("Debugging"),
00033                                   _("This step will enable debugging output "
00034                                     "from the CUPS scheduler.  This may "
00035                                     "cause the scheduler to restart.  Click "
00036                                     "the button below to enable debugging."))
00037         button = gtk.Button (_("Enable Debugging"))
00038         buttonbox = gtk.HButtonBox ()
00039         buttonbox.set_border_width (0)
00040         buttonbox.set_layout (gtk.BUTTONBOX_START)
00041         buttonbox.pack_start (button, False, False, 0)
00042         self.button = button
00043         page.pack_start (buttonbox, False, False, 0)
00044         self.label = gtk.Label ()
00045         self.label.set_alignment (0, 0)
00046         self.label.set_line_wrap (True)
00047         page.pack_start (self.label, False, False, 0)
00048         troubleshooter.new_page (page, self)
00049         self.persistent_answers = {}

Here is the call graph for this function:

Definition at line 50 of file ErrorLogCheckpoint.py.

00050 
00051     def __del__ (self):
00052         if not self.persistent_answers.get ('error_log_debug_logging_set',
00053                                             False):
00054             return
00055 
00056         c = self.troubleshooter.answers['_authenticated_connection']
00057         c._set_lock (False)
00058         settings = c.adminGetServerSettings ()
00059         if len (settings.keys ()) == 0:
00060             return
00061 
00062         settings[cups.CUPS_SERVER_DEBUG_LOGGING] = '0'
00063         answers = self.troubleshooter.answers
00064         orig_settings = self.persistent_answers['cups_server_settings']
00065         settings['MaxLogSize'] = orig_settings.get ('MaxLogSize', '2000000')
00066         c.adminSetServerSettings (settings)


Member Function Documentation

Reimplemented from troubleshoot.base.Question.

Definition at line 155 of file ErrorLogCheckpoint.py.

00155 
00156     def can_click_forward (self):
00157         return self.forward_allowed

Reimplemented from troubleshoot.base.Question.

Definition at line 223 of file ErrorLogCheckpoint.py.

00223 
00224     def cancel_operation (self):
00225         self.op.cancel ()
00226 
00227         # Abandon the CUPS connection and make another.
00228         answers = self.troubleshooter.answers
00229         factory = answers['_authenticated_connection_factory']
00230         self.authconn = factory.get_connection ()
00231         self.answers['_authenticated_connection'] = self.authconn

Reimplemented from troubleshoot.base.Question.

Definition at line 117 of file ErrorLogCheckpoint.py.

00117 
00118     def collect_answer (self):
00119         answers = self.troubleshooter.answers
00120         if not answers['cups_queue_listed']:
00121             return {}
00122 
00123         parent = self.troubleshooter.get_window ()
00124         self.answers.update (self.persistent_answers)
00125         if self.answers.has_key ('error_log_checkpoint'):
00126             return self.answers
00127 
00128         (tmpfd, tmpfname) = tempfile.mkstemp ()
00129         os.close (tmpfd)
00130         try:
00131             self.op = TimedOperation (self.authconn.getFile,
00132                                       args=('/admin/log/error_log', tmpfname),
00133                                       parent=parent)
00134             self.op.run ()
00135         except RuntimeError:
00136             try:
00137                 os.remove (tmpfname)
00138             except OSError:
00139                 pass
00140 
00141             return self.answers
00142         except cups.IPPError:
00143             try:
00144                 os.remove (tmpfname)
00145             except OSError:
00146                 pass
00147 
00148             return self.answers
00149 
00150         statbuf = os.stat (tmpfname)
00151         os.remove (tmpfname)
00152         self.answers['error_log_checkpoint'] = statbuf[6]
00153         self.persistent_answers['error_log_checkpoint'] = statbuf[6]
00154         return self.answers

Reimplemented from troubleshoot.base.Question.

Definition at line 110 of file ErrorLogCheckpoint.py.

00110 
00111     def connect_signals (self, handler):
00112         self.button_sigid = self.button.connect ('clicked', self.enable_clicked,
00113                                                  handler)

Reimplemented from troubleshoot.base.Question.

Definition at line 114 of file ErrorLogCheckpoint.py.

00114 
00115     def disconnect_signals (self):
00116         self.button.disconnect (self.button_sigid)

Returns True if this page should be displayed, or False
if it should be skipped.

Reimplemented from troubleshoot.base.Question.

Definition at line 67 of file ErrorLogCheckpoint.py.

00067 
00068     def display (self):
00069         self.answers = {}
00070         answers = self.troubleshooter.answers
00071         if not answers['cups_queue_listed']:
00072             return False
00073 
00074         self.authconn = answers['_authenticated_connection']
00075         parent = self.troubleshooter.get_window ()
00076 
00077         def getServerSettings ():
00078             # Fail if auth required.
00079             cups.setPasswordCB (lambda x: '')
00080             cups.setServer ('')
00081             c = cups.Connection ()
00082             return c.adminGetServerSettings ()
00083 
00084         try:
00085             self.op = TimedOperation (getServerSettings, parent=parent)
00086             settings = self.op.run ()
00087         except RuntimeError:
00088             return False
00089         except cups.IPPError:
00090             settings = {}
00091 
00092         self.forward_allowed = False
00093         self.label.set_text ('')
00094         if len (settings.keys ()) == 0:
00095             # Requires root
00096             return True
00097         else:
00098             self.persistent_answers['cups_server_settings'] = settings
00099 
00100         try:
00101             if int (settings[cups.CUPS_SERVER_DEBUG_LOGGING]) != 0:
00102                 # Already enabled
00103                 return False
00104         except KeyError:
00105             pass
00106         except ValueError:
00107             pass
00108 
00109         return True

Definition at line 158 of file ErrorLogCheckpoint.py.

00158 
00159     def enable_clicked (self, button, handler):
00160         parent = self.troubleshooter.get_window ()
00161         self.troubleshooter.busy ()
00162         try:
00163             self.op = TimedOperation (self.authconn.adminGetServerSettings,
00164                                       parent=parent)
00165             settings = self.op.run ()
00166         except (cups.IPPError, OperationCanceled):
00167             self.troubleshooter.ready ()
00168             self.forward_allowed = True
00169             handler (button)
00170             return
00171 
00172         self.persistent_answers['cups_server_settings'] = settings.copy ()
00173         MAXLOGSIZE='MaxLogSize'
00174         try:
00175             prev_debug = int (settings[cups.CUPS_SERVER_DEBUG_LOGGING])
00176         except KeyError:
00177             prev_debug = 0
00178         try:
00179             prev_logsize = int (settings[MAXLOGSIZE])
00180         except (KeyError, ValueError):
00181             prev_logsize = -1
00182 
00183         if prev_debug == 0 or prev_logsize != '0':
00184             settings[cups.CUPS_SERVER_DEBUG_LOGGING] = '1'
00185             settings[MAXLOGSIZE] = '0'
00186             success = False
00187 
00188             def set_settings (connection, settings):
00189                 connection.adminSetServerSettings (settings)
00190 
00191                 # Now reconnect.
00192                 attempt = 1
00193                 while attempt <= 5:
00194                     try:
00195                         time.sleep (1)
00196                         connection._connect ()
00197                         break
00198                     except RuntimeError:
00199                         # Connection failed
00200                         attempt += 1
00201 
00202             try:
00203                 debugprint ("Settings to set: " + repr (settings))
00204                 self.op = TimedOperation (set_settings,
00205                                           args=(self.authconn, settings,),
00206                                           parent=parent)
00207                 self.op.run ()
00208                 success = True
00209             except cups.IPPError:
00210                 pass
00211             except RuntimeError:
00212                 pass
00213 
00214             if success:
00215                 self.persistent_answers['error_log_debug_logging_set'] = True
00216                 self.label.set_text (_("Debug logging enabled."))
00217         else:
00218             self.label.set_text (_("Debug logging was already enabled."))
00219 
00220         self.forward_allowed = True
00221         self.troubleshooter.ready ()
00222         handler (button)

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 68 of file ErrorLogCheckpoint.py.

Definition at line 73 of file ErrorLogCheckpoint.py.

Definition at line 41 of file ErrorLogCheckpoint.py.

Definition at line 111 of file ErrorLogCheckpoint.py.

Definition at line 91 of file ErrorLogCheckpoint.py.

Definition at line 43 of file ErrorLogCheckpoint.py.

Definition at line 84 of file ErrorLogCheckpoint.py.

Definition at line 48 of file ErrorLogCheckpoint.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: