-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-archives.py
34 lines (27 loc) · 1018 Bytes
/
test-archives.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
30
31
32
33
34
import os
import requests
SYNBIOHUB_URL = "http://localhost:8888"
AUTH_CREDENTIALS = {"email": "[email protected]", "password": "1187277"}
HEADERS = {"Accept": "text/plain"}
auth_response = requests.post(SYNBIOHUB_URL + "/login", data=AUTH_CREDENTIALS, headers=HEADERS)
auth_token = auth_response.text
HEADERS["X-authorization"] = auth_token
os.chdir('archives')
for archive in range(980):
filename = '{0:05d}'.format(archive + 1) + ".omex"
try:
files = {"file": (filename, open(filename, 'rb'))}
except FileNotFoundError:
continue
data = {
"id": "test" + str(archive),
"version": "1",
"name": filename,
"description": "Test upload of: " + filename,
"citations": "",
"collectionChoices": "",
"overwrite_merge": "0",
"user": "zach"
}
result = requests.post(SYNBIOHUB_URL + "/submit", files=files, data=data, headers=HEADERS)
print(result.text + " " + filename)