您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

如何使用Fabric将目录复制到远程计算机?

如何使用Fabric将目录复制到远程计算机?

您也可以使用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
# ...
其他 2022/1/1 18:39:26 有377人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶