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

suppress progress status in esgfetchtables when output is not to a terminal #66

Open
alaniwi opened this issue Jun 10, 2019 · 4 comments

Comments

@alaniwi
Copy link
Collaborator

alaniwi commented Jun 10, 2019

When esgfetchtables output is redirected to a file, the file contains a mess such as:

^MFetching cmip6 tables from 01.00.30 reference: 2% | 1/48 files^MFetching cmip6 tables from 01.00.30 reference: 4% | 2/48 files^MFetching cmip6 tables from 01.00.30 reference: 6% 

(etc...)

It would be better to clean that up by suppressing this and instead just report (for each branch) one line indicating the total files, after fetching is complete. For example:

Fetched cmip6 tables from 01.00.30 reference: 48 files

Behaviour to be controlled by sys.stdout.isatty().

@glevava
Copy link
Member

glevava commented Jun 24, 2019

How did you redirect the output of the esgfetchtables?
I have no problem here:

$> esgfetchtables -p cmip6 --branch 01.00.30 --tables-dir . > log.out
$> cat log.out 
Fetching cmip6 tables from 01.00.30 reference: 100% | 48/48 files

It seems to be terminal-dependent.
Did you try using the native --log flag instead?

@alaniwi
Copy link
Collaborator Author

alaniwi commented Jun 24, 2019

What do you see if you inspect your log.out using less or some other tool? I am wondering whether your output file contains multiple lines separated by carriage-return characters, but when using cat to a terminal this is not evident.

I didn't try --log. I guess that it can be used, but this doesn't allow the user to choose the filename, or to write to a pipe.

@glevava
Copy link
Member

glevava commented Jun 24, 2019

Actually, using less or vi makes the ^M appearing.
Due to the progress bar, esgprep could be incompatible with unix pipe chain.
If you only need a log of the command-line, I can think about the --log flag to let you set the log name.

@glevava
Copy link
Member

glevava commented Aug 26, 2019

This issue is related to the untested pull request and part of the next release. To be close when release cut.

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

No branches or pull requests

2 participants