Trying to upload a file containing
~ does not do what is expected: it does not expand to
/home/user. I am not sure about other tools and other OS.
I tried to add the following checks like so (in the end I think this would better be in a specific function).
def validateVideo(path): path = os.path.normpath(os.path.expanduser(path)) if not os.path.exists(path): logger.error("No file found at path:", path) return False
But doing so also print the backtrace when the log is printed so it is not readable for a standard user.
Note: the heart of this code is
path = os.path.expanduser(path). This tells python to interpret the path like the shell does.