I am writing a simple Python script to help expedite bootstrapping my Wordpress installs and making use of wp-cli
I'm stuck at a point where I'm trying to call wp core download via a subprocess:
from subprocess import call
call(["wp", "core download"])
Which always returns
Error: This does not seem to be a WordPress install. Pass --path=
path/to/wordpressor runwp core download.
Simply running the above from the python console nor from my script does not work.
Running the command directly in the shell works, of course.
I've also tried setting the PWD with os.chdir and also passing the explicit directory with the --path=... argument to no avail.
Function
subprocess.calltakes as an argument list of parameters so in you case proper call should be:Maybe for you it's better to use
subprocess.Popenwhich takes as argumentcwdeven though its usage isn't as simple as justsubprocess.call.If none of this helps maybe try running just
call(["pwd"])to see if setting CWD usingos.chdirworks as you expect.