The return value of Popen isn't the output of the program, but instead is the class instance. I believe that you could provide a cStringIO instance as the 'stdout' keyword argument, and it would capture the program's output. You could them use its getvalue() method's return value as your HttpResponse method's first arguemnt.
But you should also check the command response status, and return your choice of error message if it fails. I suspect that there's a Popen method to wait for the process to complete and check it's status. It's all in the Popen documentation, I'm sure, probably with examples. Bill On Wed, Feb 16, 2011 at 2:02 PM, juanefren <juanef...@gmail.com> wrote: > I am using wkhtmltopdf to create PDF files, how ever I don't know how > to return them properly, docs says using a single dash instead of > output file name will write that to stdout. But I don't realize how to > return that content. > > I have been trying using subprocess.Popen this way: > > r = HttpResponse(Popen(command_args), mimetype='application/pdf') > r['Content-Disposition'] = 'filename=my_file_name.pdf' > return r > > But I am not getting the result. > > The only way I have managed to work is writting to file system in > media folder, and then redirect to the url based file, but this way > doesn't look good. > > Thanks in advance. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.