Back to index

system-config-printer  1.3.9+20120706
Public Member Functions | Public Attributes
probe_printer.LpdServer Class Reference

List of all members.

Public Member Functions

def __init__
def probe_queue
def get_possible_queue_names
def destroy
def probe

Public Attributes

 hostname
 max_lpt_com
 stop

Detailed Description

Definition at line 122 of file probe_printer.py.


Constructor & Destructor Documentation

def probe_printer.LpdServer.__init__ (   self,
  hostname 
)

Definition at line 123 of file probe_printer.py.

00123 
00124     def __init__(self, hostname):
00125         self.hostname = hostname
00126         self.max_lpt_com = 8
00127         self.stop = False


Member Function Documentation

Definition at line 176 of file probe_printer.py.

00176 
00177     def destroy(self):
00178         debugprint ("LpdServer exiting: destroy called")
00179         self.stop = True

Definition at line 164 of file probe_printer.py.

00164 
00165     def get_possible_queue_names (self):
00166         candidate = ["PASSTHRU", "ps", "lp", "PORT1", ""]
00167         for nr in range (self.max_lpt_com):
00168             candidate.extend (["LPT%d" % nr,
00169                                "LPT%d_PASSTHRU" % nr,
00170                                "COM%d" % nr,
00171                                "COM%d_PASSTHRU" % nr])
00172         for nr in range (50):
00173             candidate.append ("pr%d" % nr)
00174 
00175         return candidate

Here is the caller graph for this function:

Definition at line 180 of file probe_printer.py.

00180 
00181     def probe(self):
00182         result = []
00183         for name in self.get_possible_queue_names ():
00184             while gtk.events_pending ():
00185                 gtk.main_iteration ()
00186 
00187             if self.stop:
00188                 break
00189 
00190             found = self.probe_queue(name, result)
00191             if found == None:
00192                 # Couldn't even connect.
00193                 break
00194 
00195             if not found and name.startswith ("pr"):
00196                 break
00197             time.sleep(0.1) # avoid DOS and following counter measures 
00198 
00199         return result

Here is the call graph for this function:

def probe_printer.LpdServer.probe_queue (   self,
  name,
  result 
)

Definition at line 128 of file probe_printer.py.

00128 
00129     def probe_queue(self,name, result):
00130         s = open_socket(self.hostname, 515)
00131         if not s:
00132             return None
00133         print name
00134         
00135         try:
00136             s.send('\2%s\n' % name) # cmd send job to queue
00137             data = s.recv(1024) # receive status
00138             print repr(data)
00139         except socket.error, msg:
00140             print msg
00141             try:
00142                 s.close ()
00143             except:
00144                 pass
00145 
00146             return False
00147 
00148         if len(data)>0 and ord(data[0])==0:
00149             try:
00150                 s.send('\1\n') # abort job again
00151                 s.close ()
00152             except:
00153                 pass
00154 
00155             result.append(name)
00156             return True
00157 
00158         try:
00159             s.close()
00160         except:
00161             pass
00162 
00163         return False

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 124 of file probe_printer.py.

Definition at line 125 of file probe_printer.py.

Definition at line 126 of file probe_printer.py.


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