#!/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")
网友评论