Back to index

system-config-printer  1.3.9+20120706
Public Member Functions | Public Attributes | Private Member Functions
test-cups-driver.Driver Class Reference

List of all members.

Public Member Functions

def __init__
def list
def cat

Public Attributes

 exe
 ppds
 files

Private Member Functions

def _alarm

Detailed Description

Definition at line 47 of file test-cups-driver.py.


Constructor & Destructor Documentation

def test-cups-driver.Driver.__init__ (   self,
  driver 
)

Definition at line 48 of file test-cups-driver.py.

00048 
00049     def __init__ (self, driver):
00050         self.exe = "/usr/lib/cups/driver/%s" % driver
00051        self.ppds = None
00052        self.files = {}
00053         signal.signal (signal.SIGALRM, self._alarm)


Member Function Documentation

def test-cups-driver.Driver._alarm (   self,
  sig,
  stack 
) [private]

Definition at line 54 of file test-cups-driver.py.

00054 
00055     def _alarm (self, sig, stack):
00056         raise TimedOut

def test-cups-driver.Driver.cat (   self,
  name 
)

Definition at line 86 of file test-cups-driver.py.

00086 
00087     def cat (self, name):
00088         try:
00089             return self.files[name]
00090        except KeyError:
00091             signal.alarm (10)
00092             p = subprocess.Popen ([self.exe, "cat", name],
00093                                   stdout=subprocess.PIPE,
00094                                   stderr=subprocess.PIPE)
00095             try:
00096                 (stdout, stderr) = p.communicate ()
00097                 signal.alarm (0)
00098             except TimedOut:
00099                 posix.kill (p.pid, signal.SIGKILL)
00100                 raise
00101 
00102             if stderr:
00103                 print >> sys.stderr, stderr
00104 
00105             self.files[name] = stdout
00106             return stdout
00107 
opts, args = getopt (sys.argv[1:], "m:")
def test-cups-driver.Driver.list (   self)

Definition at line 57 of file test-cups-driver.py.

00057 
00058     def list (self):
00059         if self.ppds:
00060               return self.ppds
00061 
00062         signal.alarm (60)
00063         p = subprocess.Popen ([self.exe, "list"],
00064                               stdout=subprocess.PIPE,
00065                               stderr=subprocess.PIPE)
00066         try:
00067             (stdout, stderr) = p.communicate ()
00068             signal.alarm (0)
00069         except TimedOut:
00070             posix.kill (p.pid, signal.SIGKILL)
00071             raise
00072 
00073        if stderr:
00074               print >> sys.stderr, stderr
00075 
00076        ppds = []
00077        lines = stdout.split ('\n')
00078        for line in lines:
00079               l = shlex.split (line)
00080               if len (l) < 1:
00081                      continue
00082               ppds.append (l[0])
00083 
00084        self.ppds = ppds
00085        return ppds


Member Data Documentation

test-cups-driver.Driver.exe

Definition at line 49 of file test-cups-driver.py.

test-cups-driver.Driver.files

Definition at line 51 of file test-cups-driver.py.

test-cups-driver.Driver.ppds

Definition at line 50 of file test-cups-driver.py.


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