美文网首页
2019-02-20 fabric work with git

2019-02-20 fabric work with git

作者: 夸克星 | 来源:发表于2019-02-20 18:19 被阅读0次
    #!/usr/bin/python3
    # -*- coding:utf-8 -*-
    # __author__ = 'liao gao xiang'
    
    from invoke import Responder
    from fabric import Connection
    
    if __name__ == "__main__":
        # 用户名、密码、端口、连接超时时间
        # c = Connection("shiyanlou@172.168.10.3:22", connect_timeout=10)  # 简写
        c = Connection(host="172.168.10.3", user="shiyanlou", port=22, connect_timeout=10)
        skip = Responder(pattern=r'connecting|\(yes/no\)', response='yes\n')  # 如果有登录认证环境输入yes
        result = c.run("git clone https://github.com/fabric/fabric.git", pty=True, watchers=[skip])
        if result.ok:
            print("主机{}代码发布成功,操作用户用户为{}".format(result.host, result.user))
        # 初始化git仓库
        c.run("cd fabric && git init")
        # 查看文件状态
        c.run("cd fabric && git status")
    

    相关文章

      网友评论

          本文标题:2019-02-20 fabric work with git

          本文链接:https://www.haomeiwen.com/subject/cyfkyqtx.html