-
Notifications
You must be signed in to change notification settings - Fork 0
/
sender.py
35 lines (24 loc) · 1.03 KB
/
sender.py
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
import requests
import time
import os
from requests.auth import HTTPBasicAuth
import json
organization = os.environ['SC_ORG']
token = os.environ['SC_TOKEN']
project = os.environ['PROJECT_KEY']
x = requests.post(f'https://dev.sc-dev.io/api/projects/create?organization={organization}&name={project}&project={project}',
auth=HTTPBasicAuth(token, ''))
print(x.text)
files = {'report': open(f'/Users/tom/Downloads/{project}.zip','rb')}
x = requests.post(f'https://dev.sc-dev.io/api/ce/submit?projectKey={project}&organization={organization}',
auth=HTTPBasicAuth(token, ''),
files=files)
taskId = json.loads(x.text)['taskId']
status = "PENDING"
while status != 'FAILED':
status = json.loads(requests.get(f'https://dev.sc-dev.io/api/ce/task?id={taskId}',
auth=HTTPBasicAuth(token, '')).text)['task']['status']
print(status)
time.sleep(1)
x = requests.post(f'https://dev.sc-dev.io/api/projects/delete?project={project}',
auth=HTTPBasicAuth(token, ''))