From 1edbdb3cfd3ebb48bcf7a784d2dbb1379f0cccb8 Mon Sep 17 00:00:00 2001 From: Georg Martius Date: Tue, 12 Jun 2018 09:20:21 +0200 Subject: [PATCH] glass database: use referencepath as fallback path and added exception if paths cannot be found --- ray_tracing/glass_function/refractiveIndex.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ray_tracing/glass_function/refractiveIndex.py b/ray_tracing/glass_function/refractiveIndex.py index 7400287..5318eeb 100755 --- a/ray_tracing/glass_function/refractiveIndex.py +++ b/ray_tracing/glass_function/refractiveIndex.py @@ -21,7 +21,7 @@ import yaml import sys import argparse -import numpy +import numpy class RefractiveIndex: @@ -60,6 +60,10 @@ def __init__(self, databasePath=os.path.join(os.path.dirname(os.path.realpath(__ def getMaterialFilename(self, shelf, book, page): cwd = os.getcwd() rootdir = cwd + "/opticspy/ray_tracing/glass_database/" + if not os.path.exists(rootdir): + rootdir = self.referencePath + if not os.path.exists(rootdir): + raise FileNotFoundError(errno.ENOENT, os.strerror(errno.ENOENT), rootdir) glass_catalog = book filename = page + '.yml' for root, subFolders, files in os.walk(rootdir):