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
Comments
I am interested in tackling this one. |
@cslycord from what I can see so far the errors are being written to STDERR. What am I missing? Thank you for the help!
|
When I redirect stderr, everything goes to the screen regardless. As you
can see in the following, the redirrecting to NULL results in output to the
screen, same with redirecting to errors.txt, and the errors.txt file gets
created but is empty (0 bytes in size).
I'm using version 2020.03.24 in alpine linux, if that makes any difference.
$ python3 ./youtube-dl -U
ERROR: can't find the current version. Please try again later.
$ python3 ./youtube-dl -U 2>/dev/null
ERROR: can't find the current version. Please try again later.
$ python3 ./youtube-dl -U 2>errors.txt
ERROR: can't find the current version. Please try again later.
$ stat errors.txt
File: errors.txt
Size: 0 Blocks: 0 IO Block: 512 regular empty
file
Device: 2h/2d Inode: 3940649674048836 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 1000/ user) Gid: ( 1001/ user)
Access: 2020-03-31 01:38:42.000000000
Modify: 2020-03-31 01:38:42.000000000
Change: 2020-03-31 01:38:42.000000000
$ cat errors.txt
$
…On Tue, Mar 31, 2020 at 10:26 AM Joshua Walden ***@***.***> wrote:
@cslycord <https://github.com/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.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#24535 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AC5TL7LQQTHBZHTCPJQTHBDRKFBERANCNFSM4LWF7HBA>
.
|
@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. |
If you look at youtube_dl/update.py |
~/youtube-dl$ grep "to_screen('ERROR" ./youtube_dl/update.py -n |
@cslycord Thank you! I will get those knocked out! |
On a related note, none of those seem to generate a failing exit code. |
@cslycord I will check that one out after this pull. Thank you. |
@cslycord is there any way you could assign this one to me while I am working on it? |
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. |
@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. |
@cslycord The errors should be going to stderr now. Take a look at my patch and see if that looks good. Thank you! |
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. |
@cslycord I updated the pull request. I added code for the return code. What do you think? Does this close this issue off? |
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
The text was updated successfully, but these errors were encountered: