Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors written to screen instead of stderr #24535

Open
cslycord opened this issue Mar 30, 2020 · 15 comments
Open

Errors written to screen instead of stderr #24535

cslycord opened this issue Mar 30, 2020 · 15 comments

Comments

@cslycord
Copy link

Errors are printed to screen directly instead of error stream (stderr)

stderr is used for errors and/or warnings, but in youtube-dl, errors are written specifically to the output screen through a "to_screen" function. It would be preferrable to direct errors to stderr to allow for error redirection for logs/etc.

For instance, in the following, I cannot store a copy of the error message in the standard way for redirection.

~$ sudo python3 /usr/local/bin/youtube-dl --version 2020.03.24 ~$ sudo python3 /usr/local/bin/youtube-dl -U ERROR: can't find the current version. Please try again later. ~$ sudo python3 /usr/local/bin/youtube-dl -U 2>./youtube_errors ERROR: can't find the current version. Please try again later. ~$ du -hsx youtube_errors 0 youtube_errors

@WaldenJosh
Copy link

I am interested in tackling this one.

@WaldenJosh
Copy link

@cslycord from what I can see so far the errors are being written to STDERR. What am I missing? Thank you for the help!

(venv) C:\Users\joshu\PycharmProjects\youtube-dl\bin>python .\youtube-dl 2> error.txt

(venv) C:\Users\joshu\PycharmProjects\youtube-dl\bin>

error.txt
Usage: youtube-dl [OPTIONS] URL [URL...]

youtube-dl: error: You must provide at least one URL.
Type youtube-dl --help to see a list of all options.

@cslycord
Copy link
Author

cslycord commented Mar 31, 2020 via email

@WaldenJosh
Copy link

@cslycord thank you for getting back to me. I am running the same version as you but I was testing on Windows 10. I will fire up Linux tomorrow and do testing there.

@cslycord
Copy link
Author

If you look at youtube_dl/update.py
there are many instances of calls to "to_screen('Error _________')" followed by a return.

@cslycord
Copy link
Author

~/youtube-dl$ grep "to_screen('ERROR" ./youtube_dl/update.py -n
50: to_screen('ERROR: can't find the current version. Please try again later.')
63: to_screen('ERROR: can't obtain versions info. Please try again later.')
66: to_screen('ERROR: the versions file is not signed or corrupted. Aborting.')
71: to_screen('ERROR: the versions file signature is invalid. Aborting.')
93: to_screen('ERROR: no write permissions on %s' % filename)
101: to_screen('ERROR: no write permissions on %s' % directory)
111: to_screen('ERROR: unable to download latest version')
116: to_screen('ERROR: the downloaded file hash does not match. Aborting.')
125: to_screen('ERROR: unable to write the new version')
145: to_screen('ERROR: unable to overwrite current version')
157: to_screen('ERROR: unable to download latest version')
162: to_screen('ERROR: the downloaded file hash does not match. Aborting.')
171: to_screen('ERROR: unable to overwrite current version')

@WaldenJosh
Copy link

@cslycord Thank you! I will get those knocked out!

@cslycord
Copy link
Author

On a related note, none of those seem to generate a failing exit code.

#2395

@WaldenJosh
Copy link

@cslycord I will check that one out after this pull. Thank you.

@WaldenJosh
Copy link

@cslycord is there any way you could assign this one to me while I am working on it?

@cslycord
Copy link
Author

cslycord commented Apr 1, 2020

I'm not sure how. On my end, all I seem to be able to do is add/edit comments and at the top, if I tap to edit the issue, that just allows me to modify the title.

I'm guessing that since I'm not a collaborator on the project, it won't allow me to assign stuff.

@WaldenJosh
Copy link

@cslycord Ok. Now worries. Hopefully one of the contributors can stop by and put me in. I am just working on wrapping my head around the project right now.

@WaldenJosh
Copy link

@cslycord The errors should be going to stderr now. Take a look at my patch and see if that looks good. Thank you!

@cslycord
Copy link
Author

cslycord commented Apr 8, 2020

The patch looks good for the error printing.

Although, it looks like they will still produce no actual "errors" as in each case, it still issues a simple "return" that'll generate a success code.

@WaldenJosh
Copy link

@cslycord I updated the pull request. I added code for the return code. What do you think? Does this close this issue off?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants