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


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


source


as simple as



import os
os.chdir(path)

      

+6


source







All Articles