๐ปTech/๐จ๐ปetc
CDSW jobs api ํธ์ถ Python ์ฝ๋
_viper_
2021. 2. 19. 11:19
๋ฐ์ํ
โพ start
import sys, requests
if len(sys.argv) > 1:
job_id = sys.argv[1]
else :
print ("Please Input Job ID")
exit()
url = "http://cdsw.local.com/api/v1/projects/admin/python-example/jobs/" + job_id + "/start"
user = "ua64c7h1ghddrbyexf5rf9svbbwhnsl1"
password = ""
headers = {'Content-Type': 'application/json; charset=utf-8'}
r = requests.post(url, auth=(user,password), headers=headers)
if r.status_code == 200 :
print("Success Start Job")
else :
print("Fail Start Job")
โพ status
import sys, requests
if len(sys.argv) > 1:
job_id = sys.argv[1]
else :
print ("Please Input Job ID")
exit()
url = "http://cdsw.local.com/api/v1/projects/admin/python-example/jobs/" + job_id
user = "ua64c7h1ghddrbyexf5rf9svbbwhnsl1"
password = ""
r = requests.get(url, auth=(user, password))
json_data = r.json()
json_latest = json_data["latest"]
job_name = json_data["name"]
job_status = json_latest["status"]
print ("job name: " + job_name + " ,job_status: " + job_status)