Back to index

plone3  3.1.7
Public Member Functions | Public Attributes | Static Public Attributes | Private Attributes | Static Private Attributes
PortalTransforms.libtransforms.commandtransform.popentransform Class Reference
Collaboration diagram for PortalTransforms.libtransforms.commandtransform.popentransform:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def name
def getData
def convert

Public Attributes

 binary
 binaryArgs

Static Public Attributes

string binaryName = ""
string binaryArgs = ""
 useStdin = True

Private Attributes

 __name__

Static Private Attributes

 __implements__ = itransform

Detailed Description

abstract class for external command based transform

Command must read from stdin and write to stdout

Definition at line 55 of file commandtransform.py.


Constructor & Destructor Documentation

def PortalTransforms.libtransforms.commandtransform.popentransform.__init__ (   self,
  name = None,
  binary = None,
  binaryArgs = None,
  useStdin = None,
  kwargs 
)

Definition at line 67 of file commandtransform.py.

00067 
00068                  **kwargs):
00069         if name is not None:
00070             self.__name__ = name
00071         if binary is not None:
00072             self.binary = bin_search(binary)
00073         else:
00074             self.binary = bin_search(self.binaryName)
00075         if binaryArgs is not None:
00076             self.binaryArgs = binaryArgs
00077         if useStdin is not None:
00078             self.useStdin = useStdin


Member Function Documentation

def PortalTransforms.libtransforms.commandtransform.popentransform.convert (   self,
  data,
  cache,
  kwargs 
)

Definition at line 85 of file commandtransform.py.

00085 
00086     def convert(self, data, cache, **kwargs):
00087         command = "%s %s" % (self.binary, self.binaryArgs)
00088         if not self.useStdin:
00089             tmpfile, tmpname = tempfile.mkstemp(text=False) # create tmp
00090             os.write(tmpfile, data) # write data to tmp using a file descriptor
00091             os.close(tmpfile)       # close it so the other process can read it
00092             command = command % { 'infile' : tmpname } # apply tmp name to command
00093 
00094         cin, couterr = os.popen4(command, 'b')
00095 
00096         if self.useStdin:
00097             cin.write(data)
00098 
00099         status = cin.close()
00100 
00101         out = self.getData(couterr)
00102         couterr.close()
00103 
00104         if not self.useStdin:
00105             # remove tmp file
00106             os.unlink(tmpname)
00107 
00108         cache.setData(out)
00109         return cache

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 82 of file commandtransform.py.

00082 
00083     def getData(self, couterr):
00084         return couterr.read()

Here is the caller graph for this function:

Definition at line 79 of file commandtransform.py.

00079 
00080     def name(self):
00081         return self.__name__

Here is the caller graph for this function:


Member Data Documentation

Definition at line 60 of file commandtransform.py.

Definition at line 69 of file commandtransform.py.

Definition at line 71 of file commandtransform.py.

Definition at line 63 of file commandtransform.py.

Definition at line 75 of file commandtransform.py.

Definition at line 62 of file commandtransform.py.

Definition at line 64 of file commandtransform.py.


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