python调用azkaban接口上传文件

python调用

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
import os.path  

import requests

def login_azkaban():
headers = {
"Content-Type": "application/x-www-form-urlencoded"
}
data = {
'action': 'login',
'username': 'azkaban',
'password': 'azkaban',
}
response = requests.post('http://192.168.x.x:8081/manager', data=data, headers=headers)
res_data = response.json()
if "error" in res_data:
return ""
return res_data["session.id"]


def upload_project_zip(session_id, project_name, zip_file):
files = {
'file': (
os.path.basename(zip_file), open(zip_file, 'rb'), 'application/zip')
,
'ajax': (None, 'upload', 'application/x-www-form-urlencoded'),
'project': (None, project_name, 'type/plain'),
'session.id': (None, session_id, 'application/x-www-form-urlencoded')
}
response = requests.post(
'http://192.168.x.x:8081/manager', files=files)
return response.json()

本博客所有文章除特别声明外,均采用 CC BY-SA 4.0 协议 ,转载请注明出处!