[Tutor] Piping stdout to external Program

richard python at keep-trying.com
Sun Feb 1 20:31:56 EST 2004


Folks,

Having given up on my dialog box problem for moment. I have
progressed onto other things. I am attempting to create and
preview pdf reports. I have no problems creating the pdf saving
it to disk then manually opening it using reportlabs.What I wish
to do is pipe the pdf straight to acrobat reader.

This is what I have so far:

(To get the pdf output -> c.save() )
The function is to escape the spaces correctly. (taken for the newsgroups)

 >>> def _quote(*args):
...     fmt = max(map(lambda s: len(string.split(s)), args))>1 and '"%s"' 
or '%s'
...     return fmt % string.join(map(lambda s: len(string.split(s))>1 and 
'"%s"' % s or s, args),' ')

os.system(_quote(r'C:\Program Files\Adobe\Acrobat 6.0\Reader\AcroRd32.exe', 
c.save()))

This gets me the following:

(1) A new command/dos box which locks python
(2) After waiting a minute dismissing the dos box results in Acrobat coming up
minus the document
(3) The pdf document is simply outputted to the screen.

Similar problems with popen.

Is it possible to do this??

XP,Python 2.3

Regards

Richard




More information about the Tutor mailing list