[Zope] running pg_dump on windows as external method

Garry Saddington garry at schoolteachers.co.uk
Fri Oct 26 15:32:58 EDT 2007


On Friday 26 October 2007 05:24, Andreas Jung wrote:
> --On 25. Oktober 2007 22:48:42 +0100 Garry Saddington
>
> <garry at schoolteachers.co.uk> wrote:
> > I am using zope on windows with an external python method to backup my
> > database. I am struggling to run the following command:
> >
> > pg_dump.exe database > file
> >
> > I have tried using os.popen - no luck
> > and also subprocess.Popen.
> >
> > eg:
> > import subprocess
> >        
> > subprocess.Popen(['c:/dir/dir/pg_dump.exe','database','>','c:/dir/dir/out
> > put  file'])
>
> - play with the shell=True|False parameter of Popen()
> - why do you use redirection since Popen() provides a proper mechansim for
>   reading stderr/stdout
> - where is your code where you are calling wait()???
I have done this. I can get the database dump written to a file using 
subprocess and os.popen by using python on the command line or by using the 
python interpreter of the same python that runs zope.

eg. this works outside zope:
import os
os.popen('pg_dump.exe database > outfile.txt')

The same code in an external method does nothing. 


        
(Zope 2.9.0, python 2.4.2, win32) 

regards
garry


More information about the Zope mailing list