Back to index

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

List of all members.

Public Member Functions

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

Public Attributes

 troubleshooter
 answers

Detailed Description

Definition at line 31 of file CheckPrinterSanity.py.


Constructor & Destructor Documentation

Definition at line 32 of file CheckPrinterSanity.py.

00032 
00033     def __init__ (self, troubleshooter):
00034         Question.__init__ (self, troubleshooter, "Check printer sanity")
00035         troubleshooter.new_page (gtk.Label (), self)
00036         self.troubleshooter = troubleshooter


Member Function Documentation

def troubleshoot.base.Question.cancel_operation (   self) [inherited]

Reimplemented from troubleshoot.base.Question.

Definition at line 135 of file CheckPrinterSanity.py.

00135 
00136     def collect_answer (self):
00137         return self.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 37 of file CheckPrinterSanity.py.

00037 
00038     def display (self):
00039         # Collect information useful for the various checks.
00040 
00041         self.answers = {}
00042 
00043         answers = self.troubleshooter.answers
00044         if not answers['cups_queue_listed']:
00045             return False
00046 
00047         name = answers['cups_queue']
00048 
00049         parent = self.troubleshooter.get_window ()
00050 
00051         # Find out if this is a printer or a class.
00052         try:
00053             cups.setServer ('')
00054             c = TimedOperation (cups.Connection, parent=parent).run ()
00055             printers = TimedOperation (c.getPrinters, parent=parent).run ()
00056             if printers.has_key (name):
00057                 self.answers['is_cups_class'] = False
00058                 queue = printers[name]
00059                 self.answers['cups_printer_dict'] = queue
00060             else:
00061                 self.answers['is_cups_class'] = True
00062                 classes = TimedOperation (c.getClasses, parent=parent).run ()
00063                 queue = classes[name]
00064                 self.answers['cups_class_dict'] = queue
00065 
00066             attrs = TimedOperation (c.getPrinterAttributes, (name,),
00067                                     parent=parent).run ()
00068             self.answers['local_cups_queue_attributes'] = attrs
00069         except:
00070             pass
00071 
00072         if self.answers.has_key ('cups_printer_dict'):
00073             cups_printer_dict = self.answers['cups_printer_dict']
00074             uri = cups_printer_dict['device-uri']
00075             (scheme, rest) = urllib.splittype (uri)
00076             self.answers['cups_device_uri_scheme'] = scheme
00077             if scheme in ["ipp", "http", "https"]:
00078                 (hostport, rest) = urllib.splithost (rest)
00079                 (host, port) = urllib.splitnport (hostport, defport=631)
00080                 self.answers['remote_server_name'] = host
00081                 self.answers['remote_server_port'] = port
00082             elif scheme == "smb":
00083                 u = smburi.SMBURI (uri)
00084                 (group, host, share, user, password) = u.separate ()
00085                 new_environ = os.environ.copy()
00086                 new_environ['LC_ALL'] = "C"
00087                 if group:
00088                     args = ["nmblookup", "-W", group, host]
00089                 else:
00090                     args = ["nmblookup", host]
00091                 try:
00092                     p = TimedSubprocess (parent=parent,
00093                                          timeout=5000,
00094                                          args=args,
00095                                          env=new_environ,
00096                                          close_fds=True,
00097                                          stdin=file("/dev/null"),
00098                                          stdout=subprocess.PIPE,
00099                                          stderr=subprocess.PIPE)
00100                     result = p.run ()
00101                     self.answers['nmblookup_output'] = result
00102                     for line in result[0]:
00103                         if line.startswith ("querying"):
00104                             continue
00105                         spc = line.find (' ')
00106                         if (spc != -1 and
00107                             not line[spc:].startswith (" failed ")):
00108                             # Remember the IP address.
00109                             self.answers['remote_server_name'] = line[:spc]
00110                             break
00111                 except OSError:
00112                     # Problem executing command.
00113                     pass
00114             elif scheme == "hp":
00115                 new_environ = os.environ.copy()
00116                 new_environ['LC_ALL'] = "C"
00117                 new_environ['DISPLAY'] = ""
00118                 try:
00119                     p = TimedSubprocess (parent=parent,
00120                                          timeout=3000,
00121                                          args=["hp-info", "-d" + uri],
00122                                          close_fds=True,
00123                                          env=new_environ,
00124                                          stdin=file("/dev/null"),
00125                                          stdout=subprocess.PIPE,
00126                                          stderr=subprocess.PIPE)
00127                     self.answers['hplip_output'] = p.run ()
00128                 except OSError:
00129                     # Problem executing command.
00130                     pass
00131 
00132             r = cups_printer_dict['printer-type'] & cups.CUPS_PRINTER_REMOTE
00133             self.answers['cups_printer_remote'] = (r != 0)
00134         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 40 of file CheckPrinterSanity.py.

Reimplemented from troubleshoot.base.Question.

Definition at line 35 of file CheckPrinterSanity.py.


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