resourcePath raises an error with the requested and full paths if the file does not exist.
This commit is contained in:
parent
eb15c54f8b
commit
0684400668
@ -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
|
||||
|
Reference in New Issue
Block a user