您也可以使用put
它(至少在1.0.0中使用):
local_path
可以是相对或绝对本地文件或 ,并且可以包含 ,如Python 模块所理解的那样。波形扩展(由os.path.expanduser实现)也将执行。
请参阅:http ://docs.fabfile.org/en/1.0.0/api/core/operations.html#fabric.operations.put
更新:此示例对1.0.0很好(对我而言):
from fabric.api import env
from fabric.operations import run, put
env.hosts = ['frodo@middleearth.com']
def copy():
# make sure the directory is there!
run('mkdir -p /home/frodo/tmp')
# our local 'testdirectory' - it may contain files or subdirectories ...
put('testdirectory', '/home/frodo/tmp')
# [frodo@middleearth.com] Executing task 'copy'
# [frodo@middleearth.com] run: mkdir -p /home/frodo/tmp
# [frodo@middleearth.com] put: testdirectory/HELLO -> \
# /home/frodo/tmp/testdirectory/HELLO
# [frodo@middleearth.com] put: testdirectory/WORLD -> \
# /home/frodo/tmp/testdirectory/WORLD
# ...