简体   繁体   中英

How to change the current working directory

Using invoke , how can I change the directory that the run call operates in?

In Fabric, one would

from fabric.context_managers import lcd
with lcd('foo'):
   local('do')

to run do in the foo directory, but I can't find a similar import in pyinvoke.

as simple as that

import os
os.chdir(path)

Use Context.cd

Take a look at docs

with ctx.cd('/path/targeted'):
    # do something in /path/targeted

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM