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

import utils
import initialize
from conf import conf
from conf import sf
import exceptions
import database

def boot(config, to_database = True):
	try:
		out = utils.callsubprocess('boot', conf.boot_command, conf.boot_output, \
				True, timeout = conf.boot_timeout)
		result = 'nominal'
	except exceptions.ProcessFailed as e:
		result = 'failed'
		out = e.output
		traceback.print_exc()
	except exceptions.ProcessTimeout as e:
		result = 'timeout'
		out = e.output
		traceback.print_exc()

	value = None
	try:
		res = utils.callsubprocess('parse_command', conf.parse_command,
				conf.parse_output, True, stdin = out)
		value = float(res[0])
	except Exception as e:
		print("W: parse exception: " + e.__str__())

	if to_database:
			dtb = database.database()
			txt = ''
			for ln in out:
				txt += ln + '\n'
			dtb.add_measure(txt, result, config.id, value)