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