Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add quiet option to silence output on stdout #135

Merged
merged 2 commits into from

2 participants

@sidprak

Inspired by: #77

@mludvig
Owner

Can you wrap it in try/except? And inside try to open /dev/null before closing stdout. Only close and reassign it if the open() succeeds. If for any reason the open fails (e.g. Windows) we want to print a warning, something along the lines of "--quit disabled", and keep stdout open the way it was.
Thanks!

@sidprak

@mludvig Addressed review comment.

@mludvig mludvig merged commit 74c961a into from
@mludvig
Owner

Thanks!

@sidprak sidprak deleted the branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 7, 2013
  1. @sidprak
Commits on Mar 8, 2013
  1. @sidprak
This page is out of date. Refresh to see the latest.
Showing with 9 additions and 0 deletions.
  1. +9 −0 s3cmd
View
9 s3cmd
@@ -1808,6 +1808,7 @@ def main():
optparser.add_option( "--version", dest="show_version", action="store_true", help="Show s3cmd version (%s) and exit." % (PkgInfo.version))
optparser.add_option("-F", "--follow-symlinks", dest="follow_symlinks", action="store_true", default=False, help="Follow symbolic links as if they are regular files")
optparser.add_option( "--cache-file", dest="cache_file", action="store", default="", metavar="FILE", help="Cache FILE containing local source MD5 values")
+ optparser.add_option("-q", "--quiet", dest="quiet", action="store_true", default=False, help="Silence output on stdout")
optparser.set_usage(optparser.usage + " COMMAND [parameters]")
optparser.set_description('S3cmd is a tool for managing objects in '+
@@ -1830,6 +1831,14 @@ def main():
output(u"s3cmd version %s" % PkgInfo.version)
sys.exit(0)
+ if options.quiet:
+ try:
+ f = open("/dev/null", "w")
+ sys.stdout.close()
+ sys.stdout = f
+ except IOError:
+ warning(u"--quiet disabled.")
+
## Now finally parse the config file
if not options.config:
error(u"Can't find a config file. Please use --config option.")
Something went wrong with that request. Please try again.