一直以来都是复制粘贴或者拖动文件完成部署,实在是低效得很!学了学fabric,写个了脚本。如下:
from fabric import Connection
import shutil HOST = '' # ip
USERNAME = ''
PORT = # port number
PASSWORD = ''
c = Connection(host=HOST, user=USERNAME, port=PORT, connect_kwargs={'password': PASSWORD})
shutil.make_archive('test_archive', 'gztar', 'myapp')
c.put('test_archive.tar.gz', '/home/test')
c.run('tar -C /home/test -zxvf /home/test/test_archive.tar.gz')
功能挺简单。算个记录吧。官网上传文件的说明在这里。