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).
defvalidateVideo(path):path=os.path.normpath(os.path.expanduser(path))ifnotos.path.exists(path):logger.error("No file found at path:",path)returnFalse
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.
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).
```py
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.
I think adding try/catch and adding the error logger in the catch block should avoid too many backtrace.
I'll see to add this in the code and test if try/catch reduce verbosity, if not, perhaps some options about the logger will do the job, I'll keep you informed ;-)
Thanks!
Good catch!
I think adding try/catch and adding the error logger in the catch block should avoid too many backtrace.
I'll see to add this in the code and test if try/catch reduce verbosity, if not, perhaps some options about the logger will do the job, I'll keep you informed ;-)
Thanks!
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).
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.Good catch!
I think adding try/catch and adding the error logger in the catch block should avoid too many backtrace.
I'll see to add this in the code and test if try/catch reduce verbosity, if not, perhaps some options about the logger will do the job, I'll keep you informed ;-)
Thanks!