def load_meas_file(filename=None):
global LogDir, KernelDir, AWGDir, meas_file
if filename:
meas_file = filename
else:
meas_file = find_meas_file()
with open(meas_file, 'r') as fid:
Loader.add_constructor('!include', Loader.include)
load = Loader(fid)
code = load.get_single_data()
load.dispose()
# Get the config values out of the measure_file.
if not 'config' in code.keys():
raise KeyError("Could not find config section of the yaml file.")
if 'AWGDir' in code['config'].keys():
AWGDir = os.path.abspath(code['config']['AWGDir'])
else:
raise KeyError("Could not find AWGDir in the YAML config section")
if 'KernelDir' in code['config'].keys():
KernelDir = os.path.abspath(code['config']['KernelDir'])
else:
raise KeyError("Could not find KernelDir in the YAML config section")
if 'LogDir' in code['config'].keys():
LogDir = os.path.abspath(code['config']['LogDir'])
else:
raise KeyError("Could not find LogDir in the YAML config section")
# Create directories if necessary
for d in [KernelDir, LogDir]:
if not os.path.isdir(d):
os.mkdir(d)
return code
评论列表
文章目录