Back to index

system-config-printer  1.3.9+20120706
Public Member Functions | Private Attributes
asyncpk1._WriteToTmpFile Class Reference

List of all members.

Public Member Functions

def __init__
def __del__
def get_filename
def reply_handler
def error_handler

Private Attributes

 _reply_handler
 _error_handler
 _filename
 _kwds

Detailed Description

Definition at line 153 of file asyncpk1.py.


Constructor & Destructor Documentation

def asyncpk1._WriteToTmpFile.__init__ (   self,
  kwds,
  reply_handler,
  error_handler 
)

Definition at line 154 of file asyncpk1.py.

00154 
00155     def __init__ (self, kwds, reply_handler, error_handler):
00156         self._reply_handler = reply_handler
00157         self._error_handler = error_handler
00158 
00159         # Create the temporary file in /tmp to ensure that
00160         # cups-pk-helper-mechanism is able to write to it.
00161         (tmpfd, tmpfname) = tempfile.mkstemp (dir="/tmp")
00162         os.close (tmpfd)
00163         self._filename = tmpfname
00164         debugprint ("Created tempfile %s" % tmpfname)
00165         self._kwds = kwds

Definition at line 166 of file asyncpk1.py.

00166 
00167     def __del__ (self):
00168         try:
00169             os.unlink (self._filename)
00170             debug.debugprint ("Removed tempfile %s" % self._filename)
00171         except:
00172             debug.debugprint ("No tempfile to remove")


Member Function Documentation

def asyncpk1._WriteToTmpFile.error_handler (   self,
  conn,
  exc 
)

Definition at line 197 of file asyncpk1.py.

00197 
00198     def error_handler (self, conn, exc):
00199         self._error_handler (conn, exc)

Here is the caller graph for this function:

Definition at line 173 of file asyncpk1.py.

00173 
00174     def get_filename (self):
00175         return self._filename

def asyncpk1._WriteToTmpFile.reply_handler (   self,
  conn,
  none 
)

Definition at line 176 of file asyncpk1.py.

00176 
00177     def reply_handler (self, conn, none):
00178         tmpfd = os.open (self._filename, os.O_RDONLY)
00179         tmpfile = os.fdopen (tmpfd, 'r')
00180         if self._kwds.has_key ("fd"):
00181             fd = self._kwds["fd"]
00182             os.lseek (fd, 0, os.SEEK_SET)
00183             line = tmpfile.readline ()
00184             while line != '':
00185                 os.write (fd, line)
00186                 line = tempfile.readline ()
00187         else:
00188             file_object = self._kwds["file"]
00189             file_object.seek (0)
00190             line = tmpfile.readline ()
00191             while line != '':
00192                 file_object.write (line)
00193                 line = tmpfile.readline ()
00194 
00195         tmpfile.close ()
00196         self._reply_handler (conn, none)


Member Data Documentation

Definition at line 156 of file asyncpk1.py.

Definition at line 162 of file asyncpk1.py.

Definition at line 164 of file asyncpk1.py.

Definition at line 155 of file asyncpk1.py.


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