-
Notifications
You must be signed in to change notification settings - Fork 0
/
getdata.py
executable file
·68 lines (53 loc) · 1.68 KB
/
getdata.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env python3
import getpass
import os
from boaapi.boa_client import BoaClient
from boaapi.status import CompilerStatus, ExecutionStatus
client = None
def getclient():
global client
if not client:
client = BoaClient()
user = input("Username [%s]: " % getpass.getuser())
if not user:
user = getpass.getuser()
client.login(user, getpass.getpass())
print('successfully logged in to Boa API')
return client
def getoutput(id, filename=None):
if not filename:
filename = f'data/txt/boa-job{id}-output.txt'
else:
filename = f'data/txt/{filename}'
if os.path.exists(filename):
return
if not os.path.exists('data'):
os.mkdir('data')
if not os.path.exists('data/txt'):
os.mkdir('data/txt')
client = getclient()
job = client.get_job(id)
if not job.get_public():
print(f'setting {job.id} public')
job.set_public(True)
if job.is_running():
print(f'waiting on {job.id}')
if job.wait():
print(f'downloading {job.id} to {filename}')
output = job.output()
with open(filename, 'w') as f:
f.write(output)
f.flush()
del output
elif job.compiler_status is CompilerStatus.ERROR:
print(f'job {job.id} had compile error')
elif job.exec_status is ExecutionStatus.ERROR:
print(f'job {job.id} had exec error')
getoutput(97667, filename='counts.txt')
getoutput(97666, filename='hashes.txt')
getoutput(96389, filename='rq1.output.txt')
getoutput(96238, filename='rq2.output.txt')
getoutput(96390, filename='rq4.output.txt')
if client:
client.close()
print('client closed')