def lcd_task(task, cd_to):
"""
wrap a function so that it will be
executed in a specific directory on
the host machine
uses `fabric.api.lcd(dest)`
the returned function will have the same
__name__ and __doc__ as the input `task`
:param task: the function to execute
:param cd_to: the directory in which to execute
:return: a function that will be executed in `cd_to`
"""
def func(*args, **kwargs):
with lcd(cd_to):
task(*args, **kwargs)
func.__name__ = task.__name__
func.__doc__ = task.__doc__
return func
评论列表
文章目录