// set current directory if specified
orig_dir = os.getcwd()
if "_runtime" in sos_dict and "workdir" in sos_dict["_runtime"]:
os.chdir(os.path.expanduser(sos_dict["_runtime"]["workdir"]))
// set environ ...
if "_runtime" in sos_dict and "env" in sos_dict["_runtime"]:
os.environ.update(sos_dict["_runtime"]["env"])
After Change
// set current directory if specified
orig_dir = os.getcwd()
if "_runtime" in sos_dict and "workdir" in sos_dict["_runtime"]:
if not os.path.isdir(os.path.expanduser(sos_dict["_runtime"]["workdir"])):
try:
os.makedirs(os.path.expanduser(sos_dict["_runtime"]["workdir"]))
except Exception as e:
raise RuntimeError("Failed to create workdir {}".format(sos_dict["_runtime"]["workdir"]))
os.chdir(os.path.expanduser(sos_dict["_runtime"]["workdir"]))
// set environ ...
if "_runtime" in sos_dict and "env" in sos_dict["_runtime"]:
os.environ.update(sos_dict["_runtime"]["env"])