Back to index

system-config-printer  1.3.9+20120706
Classes | Functions | Variables
probe_printer Namespace Reference

Classes

class  pysmb
class  LpdServer
class  BackgroundSmbAuthContext
class  PrinterFinder

Functions

def wordsep
def open_socket
 should be ['network', 'foo bar', ' ofoo', '"', '2 3'] print wordsep ('network "foo bar" \ ofoo "\\"" 2" "3')
def display

Variables

 PYSMB_AVAILABLE = True
tuple loop = gobject.MainLoop()
list addr = sys.argv[1]
tuple p = PrinterFinder()

Class Documentation

class probe_printer::pysmb

Definition at line 39 of file probe_printer.py.


Function Documentation

def probe_printer.display (   device)

Definition at line 499 of file probe_printer.py.

00499 
00500     def display (device):
00501         if device == None:
00502             loop.quit ()

def probe_printer.open_socket (   hostname,
  port 
)

should be ['network', 'foo bar', ' ofoo', '"', '2 3'] print wordsep ('network "foo bar" \ ofoo "\\"" 2" "3')

Definition at line 92 of file probe_printer.py.

00092 
00093 def open_socket(hostname, port):
00094     try:
00095         host, port = hostname.split(":", 1)
00096     except ValueError:
00097         host = hostname
00098         
00099     s = None
00100     try:
00101         ai = socket.getaddrinfo(host, port, socket.AF_UNSPEC,
00102                                 socket.SOCK_STREAM)
00103     except socket.gaierror:
00104         ai = []
00105 
00106     for res in ai:
00107         af, socktype, proto, canonname, sa = res
00108         try:
00109             s = socket.socket(af, socktype, proto)
00110             s.settimeout(0.5)
00111         except socket.error, msg:
00112             s = None
00113             continue
00114         try:
00115             s.connect(sa)
00116         except socket.error, msg:
00117             s.close()
00118             s = None
00119             continue
00120         break
00121     return s

Here is the caller graph for this function:

def probe_printer.wordsep (   line)

Definition at line 43 of file probe_printer.py.

00043 
00044 def wordsep (line):
00045     words = []
00046     escaped = False
00047     quoted = False
00048     in_word = False
00049     word = ''
00050     n = len (line)
00051     for i in range (n):
00052         ch = line[i]
00053         if escaped:
00054             word += ch
00055             escaped = False
00056             continue
00057 
00058         if ch == '\\':
00059             in_word = True
00060             escaped = True
00061             continue
00062 
00063         if in_word:
00064             if quoted:
00065                 if ch == '"':
00066                     quoted = False
00067                 else:
00068                     word += ch
00069             elif ch.isspace ():
00070                 words.append (word)
00071                 word = ''
00072                 in_word = False
00073             elif ch == '"':
00074                 quoted = True
00075             else:
00076                 word += ch
00077         else:
00078             if ch == '"':
00079                 in_word = True
00080                 quoted = True
00081             elif not ch.isspace ():
00082                 in_word = True
00083                 word += ch
00084 
00085     if word != '':
00086         words.append (word)
00087 
00088     return words


Variable Documentation

list probe_printer.addr = sys.argv[1]

Definition at line 503 of file probe_printer.py.

tuple probe_printer.loop = gobject.MainLoop()

Definition at line 497 of file probe_printer.py.

Definition at line 504 of file probe_printer.py.

Definition at line 36 of file probe_printer.py.