-
Notifications
You must be signed in to change notification settings - Fork 0
/
batch_run.py
54 lines (41 loc) · 1.32 KB
/
batch_run.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
import json
import glob
from tqdm import tqdm
import os
import sys
import urllib2
contract_dir = 'contract_data'
cfiles = glob.glob(contract_dir+'/contract1.json')
cjson = {}
print "Loading contracts..."
for cfile in tqdm(cfiles):
cjson.update(json.loads(open(cfile).read()))
results = {}
missed = []
print "Running analysis..."
contracts = cjson.keys()
if os.path.isfile('results.json'):
old_res = json.loads(open('results.json').read())
old_res = old_res.keys()
contracts = [c for c in contracts if c not in old_res]
cores=0
job=0
if len(sys.argv)>=3:
cores = int(sys.argv[1])
job = int(sys.argv[2])
contracts = contracts[(len(contracts)/cores)*job:(len(contracts)/cores)*(job+1)]
print "Job %d: Running on %d contracts..." % (job, len(contracts))
for c in tqdm(contracts):
with open('tmp.evm','w') as of:
of.write(cjson[c][1][2:])
os.system('python oyente.py -ll 30 -s tmp.evm -j -b')
try:
results[c] = json.loads(open('tmp.evm.json').read())
except:
missed.append(c)
with open('results.json', 'w') as of:
of.write(json.dumps(results,indent=1))
with open('missed.json', 'w') as of:
of.write(json.dumps(missed,indent=1))
# urllib2.urlopen('https://dweet.io/dweet/for/oyente-%d-%d?completed=%d&missed=%d&remaining=%d' % (job,cores,len(results),len(missed),len(contracts)-len(results)-len(missed)))
print "Completed."