aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2015-08-12 10:46:27 +0200
committerKarel Kočí <cynerd@email.cz>2015-08-12 15:36:58 +0200
commitb950d11fd8c8059fc935e80816cbe27d8d0b9b7b (patch)
treebda214b9d3cdc107581ba2a2fd869d95a413c5a5
parent030dc22bc6c28faac3fadcd4a7df93a2a4147535 (diff)
downloadlinux-conf-perf-b950d11fd8c8059fc935e80816cbe27d8d0b9b7b.tar.gz
linux-conf-perf-b950d11fd8c8059fc935e80816cbe27d8d0b9b7b.tar.bz2
linux-conf-perf-b950d11fd8c8059fc935e80816cbe27d8d0b9b7b.zip
Single configuration generation ensured to generate only single
configuration per execution
-rw-r--r--scripts/configurations.py64
-rw-r--r--scripts/exceptions.py5
2 files changed, 41 insertions, 28 deletions
diff --git a/scripts/configurations.py b/scripts/configurations.py
index 5a04f38..8391140 100644
--- a/scripts/configurations.py
+++ b/scripts/configurations.py
@@ -161,31 +161,43 @@ def __register_conf__(con, conf_num, generator):
dtb.add_configuration(hsh, hshf, generator)
def __generate_single__(var_num, conf_num):
- if os.path.isfile(sf(conf.single_generated_file)):
+ measure_list = set()
+ if not os.path.isfile(sf(conf.single_generated_file)):
+ with open(sf(conf.measure_file), 'r') as fi:
+ for ln in fi:
+ measure_list.add(int(ln))
+ else:
+ with open(sf(conf.single_generated_file), 'r') as f:
+ for ln in f:
+ measure_list.add(int(ln))
+ if not measure_list:
return False
- measure_list = []
- with open(sf(conf.measure_file), 'r') as f:
- for ln in f:
- measure_list.append(int(ln))
- for measure in measure_list:
- tfile = __buildtempcnf__(var_num, (sf(conf.rules_file),
- sf(conf.fixed_file)), (str(measure)))
- try:
- confs = __exec_sat__(tfile, ['-i', '0'])
- for con in confs:
- __register_conf__(con, conf_num, 'single-sat')
- except exceptions.NoSolution:
- pass
- finally:
- os.remove(tfile)
- with open(sf(conf.single_generated_file), 'w') as f:
- f.write("This file informs scripts, that all single selected configurations are already generated.\n")
- f.write("Remove this file if you want run generating process again.")
- return True
+ tfile = __buildtempcnf__(var_num, (sf(conf.rules_file),
+ sf(conf.fixed_file)), [str(measure_list.pop())])
+ with open(sf(conf.single_generated_file), 'w') as fo:
+ for ln in measure_list:
+ fo.write(str(ln) + '\n')
+ try:
+ confs = __exec_sat__(tfile, ['-i', '0'])
+ print(confs)
+ for con in confs:
+ __register_conf__(con, conf_num, 'single-sat')
+ except exceptions.NoSolution:
+ __generate_single__(var_num, conf_num)
+ finally:
+ os.remove(tfile)
+ return True
def __generate_random__(var_num, conf_num):
# TODO
- pass
+ #tfile = __buildtempcnf__(var_num, (sf(conf.rules_file), sf(conf.fixed_file)), ())
+ #try:
+ #confs = __exec_sat__(tfile, [])
+ #for con in confs:
+ #__register_conf__(con, conf_num)
+ #finally:
+ #os.remove(tfile)
+ return False
def generate():
"""Collect boolean equations from files rules and required
@@ -204,14 +216,10 @@ def generate():
if __generate_single__(var_num, conf_num):
return
+ elif __generate_random__(var_num, conf_num):
+ return
- #tfile = __buildtempcnf__(var_num, (sf(conf.rules_file), sf(conf.fixed_file)), ())
- #try:
- #confs = __exec_sat__(tfile, [])
- #for con in confs:
- #__register_conf__(con, conf_num)
- #finally:
- #os.remove(tfile)
+ raise exceptions.NoNewConfiguration()
def compare(file1, file2):
"""Compared two configuration"""
diff --git a/scripts/exceptions.py b/scripts/exceptions.py
index 89fba0a..ac7f093 100644
--- a/scripts/exceptions.py
+++ b/scripts/exceptions.py
@@ -20,6 +20,11 @@ class ConfigurationError(Exception):
def __str__(self):
return "Configuration error: " + message
+class NoNewConfiguration(Exception):
+ def __init__(self):
+ pass
+ def __str__(self):
+ return "No new configuration generated"
class NoApplicableConfiguration(Exception):
def __init__(self):
pass