resourcePath raises an error with the requested and full paths if the file does not exist.

This commit is contained in:
David Vierra 2015-01-02 15:36:27 -10:00
parent eb15c54f8b
commit 0684400668

View File

@ -11,11 +11,15 @@ log = logging.getLogger(__name__)
def resourcePath(filename):
filename = filename.replace('/', os.path.sep)
return os.path.join(
path = os.path.join(
getattr(
sys,
"_MEIPASS",
os.path.abspath(".")
"_MEIPASS", # if pyinstaller'd
os.path.abspath("src") # if running from source
),
filename
)
if not os.path.exists(path):
raise RuntimeError("Could not get resource path for %s\n(Tried %s which does not exist)" % (filename, path))
return path