3

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.

leech
  • 8,293
  • 7
  • 62
  • 78

2 Answers2

6

as simple as that

import os
os.chdir(path)
Arnaud Aliès
  • 1,079
  • 13
  • 26
2

Use Context.cd

Take a look at docs

with ctx.cd('/path/targeted'):
    # do something in /path/targeted
l__flex__l
  • 1,388
  • 1
  • 16
  • 22