aboutsummaryrefslogtreecommitdiff
path: root/scripts/boot.py
blob: bff70d902af1c4fee7211d46e8e2107fa4de6731 (plain)
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
import os
import sys
import subprocess
import shutil
import importlib

import utils
import initialize
from conf import conf
from conf import sf
from exceptions import MissingFile

def boot():
	if not os.path.isfile((conf.nbscript)):
		initialize.gen_nbscript()
	try:
		os.mkdir(sf(conf.output_folder))
	except FileExistsError:
			pass

	bench = importlib.machinery.SourceFileLoader("module.name",
			sf(conf.benchmark_python)).load_module()

	sprc = subprocess.Popen([sf(conf.novaboot), sf(conf.nbscript)] + conf.novaboot_args,
			stdout = subprocess.PIPE)
	output = ''
	for linen in sprc.stdout:
		line = linen.decode('utf-8')
		if conf.boot_output:
			print(line, end="")
		if line.startswith('lcp-output: '):
			output += line[12:]
	print(output)

	# TODO change
	data = bench.stdoutput(output)

	iteration = 0
	with open(sf(conf.iteration_file), 'r') as f:
		iteration = int(f.readline())

	for key, val in data.items():
		with open(os.path.join(sf(conf.output_folder),key), 'w') as f:
			f.write(str(iteration) + ':' + str(val) + '\n')