How to change the current working directory
Using invoke , how can I change the directory where the call is running run
?
In Fabric one could
from fabric.context_managers import lcd
with lcd('foo'):
local('do')
to run do
in a directory foo
, but I cannot find a similar import in pyinvoke.
+3
leech
source
to share
2 answers
Use Context.cd
Take a look at the docs
with ctx.cd('/path/targeted'):
# do something in /path/targeted
+2
l__flex__l
source
to share
as simple as
import os
os.chdir(path)
+6
mou
source
to share