#56 Common path are not recognized

Open
opened 3 years ago by Zykino · 1 comments
Zykino commented 3 years ago

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.

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.
Poster
Owner

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!

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!
LecygneNoir added the
bug
label 3 years ago
LecygneNoir added the
Todo
label 3 years ago
LecygneNoir added the
enhancement
label 3 years ago
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date

No due date set.

Dependencies

This issue currently doesn't have any dependencies.

Loading…
There is no content yet.