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): def resourcePath(filename):
filename = filename.replace('/', os.path.sep) filename = filename.replace('/', os.path.sep)
return os.path.join( path = os.path.join(
getattr( getattr(
sys, sys,
"_MEIPASS", "_MEIPASS", # if pyinstaller'd
os.path.abspath(".") os.path.abspath("src") # if running from source
), ),
filename 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