superscript v 0.9.1

Former-commit-id: 246efd524b
This commit is contained in:
Arthur Lu 2021-06-13 00:49:04 +00:00
parent 4c65e88903
commit 3c7262498c

View File

@ -3,10 +3,12 @@
# Notes: # Notes:
# setup: # setup:
__version__ = "0.9.0" __version__ = "0.9.1"
# changelog should be viewed using print(analysis.__changelog__) # changelog should be viewed using print(analysis.__changelog__)
__changelog__ = """changelog: __changelog__ = """changelog:
0.9.1:
- fixed bugs in configuration item loading exception handling
0.9.0: 0.9.0:
- moved printing and logging related functions to interface.py (changelog will stay in this file) - moved printing and logging related functions to interface.py (changelog will stay in this file)
- changed function return files for load_config and save_config to standard C values (0 for success, 1 for error) - changed function return files for load_config and save_config to standard C values (0 for success, 1 for error)
@ -209,7 +211,7 @@ def main():
config = {} config = {}
if load_config(config_path, config) == 1: if load_config(config_path, config) == 1:
exit(1) sys.exit(1)
error_flag = False error_flag = False
@ -235,7 +237,7 @@ def main():
error_flag = True error_flag = True
if error_flag: if error_flag:
exit(1) sys.exit(1)
error_flag = False error_flag = False
if competition == None or competition == "": if competition == None or competition == "":
@ -252,7 +254,7 @@ def main():
error_flag = True error_flag = True
if error_flag: if error_flag:
exit(1) sys.exit(1)
log(stdout, INF, "found and loaded competition, match_tests, metrics_tests, pit_tests from config") log(stdout, INF, "found and loaded competition, match_tests, metrics_tests, pit_tests from config")
@ -261,7 +263,7 @@ def main():
cfg_max_threads = config["max-threads"] cfg_max_threads = config["max-threads"]
except: except:
log(stderr, ERR, "max-threads field in config must not be empty, refer to documentation for configuration options", code = 109) log(stderr, ERR, "max-threads field in config must not be empty, refer to documentation for configuration options", code = 109)
exit(1) sys.exit(1)
if cfg_max_threads > -sys_max_threads and cfg_max_threads < 0 : if cfg_max_threads > -sys_max_threads and cfg_max_threads < 0 :
alloc_processes = sys_max_threads + cfg_max_threads alloc_processes = sys_max_threads + cfg_max_threads
@ -273,7 +275,7 @@ def main():
alloc_processes = sys_max_threads alloc_processes = sys_max_threads
else: else:
log(stderr, ERR, "max-threads must be between -" + str(sys_max_threads) + " and " + str(sys_max_threads) + ", but got " + cfg_max_threads, code = 110) log(stderr, ERR, "max-threads must be between -" + str(sys_max_threads) + " and " + str(sys_max_threads) + ", but got " + cfg_max_threads, code = 110)
exit(1) sys.exit(1)
log(stdout, INF, "found and loaded max-threads from config") log(stdout, INF, "found and loaded max-threads from config")
log(stdout, INF, "attempting to start " + str(alloc_processes) + " threads") log(stdout, INF, "attempting to start " + str(alloc_processes) + " threads")
@ -282,7 +284,7 @@ def main():
except Exception as e: except Exception as e:
log(stderr, ERR, "unable to start threads", code = 200) log(stderr, ERR, "unable to start threads", code = 200)
log(stderr, INF, e) log(stderr, INF, e)
exit(1) sys.exit(1)
log(stdout, INF, "successfully initialized " + str(alloc_processes) + " threads") log(stdout, INF, "successfully initialized " + str(alloc_processes) + " threads")
exit_flag = False exit_flag = False
@ -290,16 +292,23 @@ def main():
try: try:
apikey = config["key"]["database"] apikey = config["key"]["database"]
except: except:
log(stderr, ERR, "database key field in config must not be empty, please populate the database key", code = 111) log(stderr, ERR, "database key field in config must be present", code = 111)
exit_flag = True exit_flag = True
try: try:
tbakey = config["key"]["tba"] tbakey = config["key"]["tba"]
except: except:
log(stderr, ERR, "tba key field in config must not be empty, please populate the tba key", code = 112) log(stderr, ERR, "tba key field in config must be present", code = 112)
exit_flag = True
if apikey == None or apikey == "":
log(stderr, ERR, "database key field in config must not be empty, please populate the database key")
exit_flag = True
if tbakey == None or tbakey == "":
log(stderr, ERR, "tba key field in config must not be empty, please populate the tba key")
exit_flag = True exit_flag = True
if exit_flag: if exit_flag:
exit(1) sys.exit(1)
log(stdout, INF, "found and loaded database and tba keys") log(stdout, INF, "found and loaded database and tba keys")