]> rtime.felk.cvut.cz Git - linux-conf-perf.git/blob - scripts/phase.py
Chnage conf paths from absolute to relative
[linux-conf-perf.git] / scripts / phase.py
1 import os
2 import sys
3
4 from conf import conf
5 from conf import sf
6
7 phases = ("Not Initialized",            #0
8                   "Initializing",                       #1
9                   "Initialized",                        #2
10                   "Solution generating",        #3
11                   "Solution generated",         #4
12                   "Solution applying",          #5
13                   "Solution applied",           #6
14                   "Kernel configuration",       #7
15                   "Kernel configured",          #8
16                   "Kernel build",                       #9
17                   "Kernel built"                        #10
18                   )
19
20 def get():
21         try:
22                 with open(sf(conf.phase_file)) as f:
23                         txtPhase = f.readline().rstrip()
24                 if not txtPhase in phases:
25                         raise PhaseMismatch()
26                 return phases.index(txtPhase)
27         except FileNotFoundError:
28                 return 0
29         
30 def set(phs):
31         with open(sf(conf.phase_file), 'w') as f:
32                 f.write(phases[phs])
33
34 def pset(str):
35         set(phase.index(str))
36
37 def phs(str):
38         return phases.index(str)
39
40 def message(phs):
41         "Prints message signaling running phase."
42         print("-- " + phases[phs])