Back to index

system-config-printer  1.3.9+20120706
Public Member Functions | Public Attributes
troubleshoot.CheckNetworkServerSanity.CheckNetworkServerSanity Class Reference
Inheritance diagram for troubleshoot.CheckNetworkServerSanity.CheckNetworkServerSanity:
Inheritance graph
[legend]
Collaboration diagram for troubleshoot.CheckNetworkServerSanity.CheckNetworkServerSanity:
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

 answers
 op
 troubleshooter

Detailed Description

Definition at line 36 of file CheckNetworkServerSanity.py.


Constructor & Destructor Documentation

Definition at line 37 of file CheckNetworkServerSanity.py.

00037 
00038     def __init__ (self, troubleshooter):
00039         Question.__init__ (self, troubleshooter, "Check network server sanity")
00040         troubleshooter.new_page (gtk.Label (), self)


Member Function Documentation

Reimplemented from troubleshoot.base.Question.

Definition at line 201 of file CheckNetworkServerSanity.py.

00201 
00202     def cancel_operation (self):
00203         self.op.cancel ()

Reimplemented from troubleshoot.base.Question.

Definition at line 198 of file CheckNetworkServerSanity.py.

00198 
00199     def collect_answer (self):
00200         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 41 of file CheckNetworkServerSanity.py.

00041 
00042     def display (self):
00043         # Collect useful information.
00044 
00045         self.answers = {}
00046         answers = self.troubleshooter.answers
00047         if (not answers.has_key ('remote_server_name') and
00048             not answers.has_key ('remote_server_ip_address')):
00049             return False
00050 
00051         parent = self.troubleshooter.get_window ()
00052 
00053         server_name = answers['remote_server_name']
00054         server_port = answers.get('remote_server_port', 631)
00055         try_connect = False
00056         if server_name:
00057             # Try resolving the hostname.
00058             try:
00059                 ai = socket.getaddrinfo (server_name, server_port)
00060                 resolves = map (lambda (family, socktype,
00061                                         proto, canonname, sockaddr):
00062                                     sockaddr[0], ai)
00063                 try_connect = True
00064             except socket.gaierror:
00065                 resolves = False
00066 
00067             self.answers['remote_server_name_resolves'] = resolves
00068 
00069             ipaddr = answers.get ('remote_server_ip_address', '')
00070             if resolves:
00071                 if ipaddr:
00072                     try:
00073                         resolves.index (ipaddr)
00074                     except ValueError:
00075                         # The IP address given doesn't match the server name.
00076                         # Use the IP address instead of the name.
00077                         server_name = ipaddr
00078                         try_connect = True
00079             elif ipaddr:
00080                 server_name = ipaddr
00081                 try_connect = True
00082         else:
00083             server_name = answers['remote_server_ip_address']
00084             # Validate it.
00085             try:
00086                 ai = socket.getaddrinfo (server_name, server_port)
00087                 resolves = map (lambda (family, socktype,
00088                                         proto, canonname, sockaddr):
00089                                     sockaddr[0], ai)
00090             except socket.gaierror:
00091                 resolves = False
00092 
00093             self.answers['remote_server_name_resolves'] = resolves
00094             try_connect = True
00095 
00096         self.answers['remote_server_try_connect'] = server_name
00097 
00098         if (try_connect and
00099             answers.get ('cups_device_uri_scheme', 'ipp') in ['ipp',
00100                                                               'http',
00101                                                               'https']):
00102             if answers.get ('cups_device_uri_scheme') == 'https':
00103                 encryption = cups.HTTP_ENCRYPT_REQUIRED
00104             else:
00105                 encryption = cups.HTTP_ENCRYPT_IF_REQUESTED
00106 
00107             try:
00108                 self.op = TimedOperation (cups.Connection,
00109                                           kwargs={"host": server_name,
00110                                                   "port": server_port,
00111                                                   "encryption": encryption},
00112                                           parent=parent)
00113                 c = self.op.run ()
00114                 ipp_connect = True
00115             except RuntimeError:
00116                 ipp_connect = False
00117 
00118             self.answers['remote_server_connect_ipp'] = ipp_connect
00119 
00120             if ipp_connect:
00121                 try:
00122                     self.op = TimedOperation (c.getPrinters, parent=parent)
00123                     self.op.run ()
00124                     cups_server = True
00125                 except:
00126                     cups_server = False
00127 
00128                 self.answers['remote_server_cups'] = cups_server
00129 
00130                 if cups_server:
00131                     cups_printer_dict = answers.get ('cups_printer_dict', {})
00132                     uri = cups_printer_dict.get ('device-uri', None)
00133                     if uri:
00134                         try:
00135                             self.op = TimedOperation (c.getPrinterAttributes,
00136                                                       kwargs={"uri": uri},
00137                                                       parent=parent)
00138                             attr = self.op.run ()
00139                             self.answers['remote_cups_queue_attributes'] = attr
00140                         except:
00141                             pass
00142 
00143         if try_connect:
00144             # Try to see if we can connect using smbc.
00145             context = None
00146             try:
00147                 context = smbc.Context ()
00148                 name = self.answers['remote_server_try_connect']
00149                 self.op = TimedOperation (context.opendir,
00150                                           args=("smb://%s/" % name,),
00151                                           parent=parent)
00152                 dir = self.op.run ()
00153                 self.op = TimedOperation (dir.getdents, parent=parent)
00154                 shares = self.op.run ()
00155                 self.answers['remote_server_smb'] = True
00156                 self.answers['remote_server_smb_shares'] = shares
00157             except NameError:
00158                 # No smbc support
00159                 pass
00160             except RuntimeError, (e, s):
00161                 self.answers['remote_server_smb_shares'] = (e, s)
00162 
00163             if context != None and answers.has_key ('cups_printer_dict'):
00164                 uri = answers['cups_printer_dict'].get ('device-uri', '')
00165                 u = smburi.SMBURI (uri)
00166                 (group, host, share, user, password) = u.separate ()
00167                 accessible = False
00168                 try:
00169                     self.op = TimedOperation (context.open,
00170                                               args=("smb://%s/%s" % (host,
00171                                                                      share),
00172                                                     os.O_RDWR,
00173                                                     0777),
00174                                               parent=parent)
00175                     f  = self.op.run ()
00176                     accessible = True
00177                 except RuntimeError, (e, s):
00178                     accessible = (e, s)
00179 
00180                 self.answers['remote_server_smb_share_anon_access'] = accessible
00181 
00182         # Try traceroute if we haven't already.
00183         if (try_connect and
00184             not answers.has_key ('remote_server_traceroute')):
00185             try:
00186                 self.op = TimedSubprocess (parent=parent, close_fds=True,
00187                                            args=['traceroute', '-w', '1',
00188                                                  server_name],
00189                                            stdin=file("/dev/null"),
00190                                            stdout=subprocess.PIPE,
00191                                            stderr=subprocess.PIPE)
00192                 self.answers['remote_server_traceroute'] = self.op.run ()
00193             except:
00194                 # Problem executing command.
00195                 pass
00196 
00197         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 44 of file CheckNetworkServerSanity.py.

Definition at line 107 of file CheckNetworkServerSanity.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: