aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2015-04-28 14:08:59 +0200
committerKarel Kočí <cynerd@email.cz>2015-04-28 14:08:59 +0200
commit4761eed66e66b7227087095f41fbfa7d235f64c9 (patch)
tree05f286a48f2108a5f6ef231517a8c72dac4b0156 /scripts
parent0baad1442c327f4376d3666b6b6cae77c544d4d2 (diff)
downloadlinux-conf-perf-4761eed66e66b7227087095f41fbfa7d235f64c9.tar.gz
linux-conf-perf-4761eed66e66b7227087095f41fbfa7d235f64c9.tar.bz2
linux-conf-perf-4761eed66e66b7227087095f41fbfa7d235f64c9.zip
Include iteration and phase code to loop
Diffstat (limited to 'scripts')
-rw-r--r--scripts/iteration.py13
-rwxr-xr-xscripts/loop.py112
-rw-r--r--scripts/phase.py44
3 files changed, 81 insertions, 88 deletions
diff --git a/scripts/iteration.py b/scripts/iteration.py
deleted file mode 100644
index ef5a3f0..0000000
--- a/scripts/iteration.py
+++ /dev/null
@@ -1,13 +0,0 @@
-from conf import conf
-from conf import sf
-
-def reset():
- with open(sf(conf.iteration_file), 'w') as f:
- f.write('0')
-
-def inc():
- with open(sf(conf.iteration_file), 'r') as f:
- it = int(f.read())
- it += 1
- with open(sf(conf.iteration_file), 'w') as f:
- f.write(str(it))
diff --git a/scripts/loop.py b/scripts/loop.py
index 83633ff..4f5cdf0 100755
--- a/scripts/loop.py
+++ b/scripts/loop.py
@@ -6,68 +6,117 @@ import signal
from threading import Thread
from conf import conf
+from conf import sf
import initialize
-import phase
import solution
import kernel
-from exceptions import MissingFile
-import iteration
import boot
+from exceptions import MissingFile
def step():
- phs = phase.get()
+ phs = phase_get()
if phs == 0:
try:
os.mkdir(conf.build_folder)
except FileExistsError:
pass
- phase.set(1)
+ phase_set(1)
elif phs == 1:
- phase.message(1)
+ phase_message(1)
initialize.parse_kconfig()
initialize.gen_requred()
- iteration.reset()
- phase.set(2)
+ iteration_reset()
+ phase_set(2)
elif phs == 2:
- phase.message(2)
- phase.set(3)
+ phase_message(2)
+ phase_set(3)
elif phs == 3:
- phase.message(3)
+ phase_message(3)
solution.generate()
- iteration.inc()
- phase.set(4)
+ iteration_inc()
+ phase_set(4)
elif phs == 4:
- phase.message(4)
- phase.set(5)
+ phase_message(4)
+ phase_set(5)
elif phs == 5:
- phase.message(5)
+ phase_message(5)
solution.apply()
- phase.set(6)
+ phase_set(6)
elif phs == 6:
- phase.message(6)
- phase.set(7)
+ phase_message(6)
+ phase_set(7)
elif phs == 7:
- phase.message(7)
+ phase_message(7)
kernel.config()
- phase.set(8)
+ phase_set(8)
elif phs == 8:
- phase.message(8)
- phase.set(9)
+ phase_message(8)
+ phase_set(9)
elif phs == 9:
- phase.message(9)
+ phase_message(9)
kernel.make()
- phase.set(10)
+ phase_set(10)
elif phs == 10:
- phase.message(10)
- phase.set(11)
+ phase_message(10)
+ phase_set(11)
elif phs == 11:
- phase.message(11)
+ phase_message(11)
boot.boot()
- phase.set(12)
+ phase_set(12)
elif phs == 12:
- phase.message(12)
- phase.set(2)
+ phase_message(12)
+ phase_set(2)
+
+# Phase #
+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
+ "System boot", #11
+ "Benchmark successful" #12
+ )
+def phase_get():
+ try:
+ with open(sf(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 phase_set(phs):
+ global thr
+ if thr.term:
+ return
+ with open(sf(conf.phase_file), 'w') as f:
+ f.write(phases[phs])
+
+def phase_message(phs):
+ "Prints message signaling running phase_"
+ print("-- " + phases[phs])
+
+# Iteration #
+def iteration_reset():
+ with open(sf(conf.iteration_file), 'w') as f:
+ f.write('0')
+
+def iteration_inc():
+ with open(sf(conf.iteration_file), 'r') as f:
+ it = int(f.readline())
+ it += 1
+ with open(sf(conf.iteration_file), 'w') as f:
+ f.write(str(it))
+
+# Thread #
class mainThread(Thread):
def __init__(self, name):
Thread.__init__(self, name=name)
@@ -76,6 +125,7 @@ class mainThread(Thread):
while not self.term:
step()
+
def loop_term():
global thr
thr.term = True
diff --git a/scripts/phase.py b/scripts/phase.py
deleted file mode 100644
index 30e61c2..0000000
--- a/scripts/phase.py
+++ /dev/null
@@ -1,44 +0,0 @@
-import os
-import sys
-
-from conf import conf
-from conf import sf
-
-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
- "System boot", #11
- "Benchmark successful" #12
- )
-
-def get():
- try:
- with open(sf(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(sf(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])