GoogleCloudPlatform / gsutil

A command line tool for interacting with cloud storage services.
Apache License 2.0
876 stars 336 forks source link

-d and -D output should go to stderr not stdout #56

Open jterrace opened 11 years ago

jterrace commented 11 years ago

Original author: paulnew...@google.com (April 05, 2011 23:37:36)

What steps will reproduce the problem?

  1. gsutil -d getacl gs://bucket_name/object_name > acl
  2. gsutil -d setacl acl gs://bucket_name/object_name

What is the expected output? What do you see instead?

I expect to see debug output on the console (via stderr) while the ACL xml is captured in the acl file.

Instead the acl file gets all the debug information as well, and cannot be used as input into the setacl command.

In general, the unix convention is to send debug output and prompts to stderr, and output meant for downstream programs to stdout. gsutil should probably follow that convention.

Original issue: http://code.google.com/p/gsutil/issues/detail?id=57

jterrace commented 11 years ago

From mfschwa...@google.com on May 20, 2011 19:15:57 Since the bulk of the output from the -d and -D options is done by httplib (which outputs simply using "print") this bug isn't feasible to fix.

jterrace commented 11 years ago

From mfschwa...@google.com on June 03, 2011 22:57:04 Ok, I change my previous assessment, because Vineeth's gsutil mods for streaming uploads/downloads reminded me of a way to solve this, by doing something like:

save_stdout = sys.stdout sys.stdout = sys.stderr sys.stdout = save_stdout

The above would cause all output to go to stderr unless specifically directed to stdout. I'm not yet convinced this is a good idea because there are parts of the code that manipulate these file-like objects (like the new streaming download implementation of the gsutil cat command); but at least it points out that it's in principle possible to get around the httplib hardcoded writes to stdout.

jterrace commented 11 years ago

From mfschwa...@google.com on February 19, 2012 19:31:56 Update: this looks like it will become possible once boto replaces the horrendous httplib with the much better Requests lib. Not sure how soon that will happen, but it's in progress now: https://github.com/boto/boto/tree/requests_refactor