aboutsummaryrefslogtreecommitdiff
path: root/scripts/phase.py
blob: 4da61b1f146f9918bcf746948cf52df4528e306c (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
import os
import sys

from conf import conf

phases = ("Not Initialized"		#0
		  "Initializing",			#1
		  "Initialized",			#2
		  "Solution generating",	#3
		  "Solution generated",		#4
		  "Solution applying",		#5
		  "Solution applied",		#6
		  "Kernel configuration",	#7
		  "Kernel configured",		#8
		  "Kernel build",			#9
		  "Kernel built"			#10
		  )

def get():
	try:
		with open(conf.phase_file) as f:
			txtPhase = f.readline().rstrip()
		if not txtPhase in phases:
			raise PhaseMismatch()
		return phases.index(txtPhase)
	except FileNotFoundError:
		return 0
	
def set(phs):
	with open(conf.phase_file, 'w') as f:
		f.write(phases[phs])

def pset(str):
	set(phase.index(str))

def phs(str):
	return phases.index(str)

def message(phs):
	"Prints message signaling running phase."
	print("-- " + phases[phs])