-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfabfile.py
More file actions
40 lines (27 loc) · 915 Bytes
/
fabfile.py
File metadata and controls
40 lines (27 loc) · 915 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!python3
# -*- coding:utf8 -*-
# fab默认采用fabfile.py作为入口代码脚本,否则就要指定 -f xxx.py
# task函数名不要用下划线,否则task名称会改变
# pip3 install fabric2
# pip3 install pyyaml
from fabric import task
from fabric import Connection
cur_remote_data_path = "/root/"
cur_remote_conn = Connection(
"root@ip",
)
def upload(file_list):
global cur_remote_conn, cur_remote_data_path
assert cur_remote_conn, "远程主机为空"
assert cur_remote_data_path, "远程数据路径为空"
for file in file_list:
print(file, "put over")
for file in file_list:
cur_remote_conn.put(file, cur_remote_data_path)
print(file, "put over")
@task
def download(c):
global cur_remote_conn
assert cur_remote_conn, "远程主机为空"
# 下载日志
cur_remote_conn.get("index.html")