Added a --simple-output option
This option turns off fancy output options like colors or progress bars. Address #649
This commit is contained in:
@@ -89,6 +89,8 @@ def main():
|
|||||||
help="Print less output. You can specify this option multiple times.")
|
help="Print less output. You can specify this option multiple times.")
|
||||||
parser.add_option("-v", "--verbose", dest="verbose", action="count", default=0,
|
parser.add_option("-v", "--verbose", dest="verbose", action="count", default=0,
|
||||||
help="Print more output. You can specify this option multiple times.")
|
help="Print more output. You can specify this option multiple times.")
|
||||||
|
parser.add_option("--simple-output", dest="simple", action="store_true", default=False,
|
||||||
|
help="Use a simple output format, with no colors or progress bars")
|
||||||
|
|
||||||
# create a group for "plugin exes" (the concept of a plugin exe is only loosly defined at this point)
|
# create a group for "plugin exes" (the concept of a plugin exe is only loosly defined at this point)
|
||||||
exegroup = OptionGroup(parser, "Other Scripts",
|
exegroup = OptionGroup(parser, "Other Scripts",
|
||||||
@@ -114,7 +116,8 @@ def main():
|
|||||||
|
|
||||||
# re-configure the logger now that we've processed the command line options
|
# re-configure the logger now that we've processed the command line options
|
||||||
logger.configure(logging.INFO + 10*options.quiet - 10*options.verbose,
|
logger.configure(logging.INFO + 10*options.quiet - 10*options.verbose,
|
||||||
options.verbose > 0)
|
verbose=options.verbose > 0,
|
||||||
|
simple=options.simple)
|
||||||
|
|
||||||
##########################################################################
|
##########################################################################
|
||||||
# This section of main() runs in response to any one-time options we have,
|
# This section of main() runs in response to any one-time options we have,
|
||||||
|
|||||||
@@ -254,7 +254,7 @@ class ANSIColorFormatter(HighlightingFormatter):
|
|||||||
# No coloring if it's not to be highlighted or colored
|
# No coloring if it's not to be highlighted or colored
|
||||||
return logging.Formatter.format(self, record)
|
return logging.Formatter.format(self, record)
|
||||||
|
|
||||||
def configure(loglevel=logging.INFO, verbose=False):
|
def configure(loglevel=logging.INFO, verbose=False, simple=False):
|
||||||
"""Configures the root logger to our liking
|
"""Configures the root logger to our liking
|
||||||
|
|
||||||
For a non-standard loglevel, pass in the level with which to configure the handler.
|
For a non-standard loglevel, pass in the level with which to configure the handler.
|
||||||
@@ -268,8 +268,10 @@ def configure(loglevel=logging.INFO, verbose=False):
|
|||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
|
|
||||||
outstream = sys.stdout
|
outstream = sys.stdout
|
||||||
|
if simple:
|
||||||
|
formatter = DumbFormatter(verbose)
|
||||||
|
|
||||||
if platform.system() == 'Windows':
|
elif platform.system() == 'Windows':
|
||||||
# Our custom output stream processor knows how to deal with select ANSI
|
# Our custom output stream processor knows how to deal with select ANSI
|
||||||
# color escape sequences
|
# color escape sequences
|
||||||
outstream = WindowsOutputStream(outstream)
|
outstream = WindowsOutputStream(outstream)
|
||||||
|
|||||||
@@ -97,7 +97,8 @@ processes = Setting(required=True, validator=int, default=-1)
|
|||||||
# ends up adding overhead and isn't worth it.
|
# ends up adding overhead and isn't worth it.
|
||||||
memcached_host = Setting(required=False, validator=str, default=None)
|
memcached_host = Setting(required=False, validator=str, default=None)
|
||||||
|
|
||||||
if platform.system() == 'Windows' or not sys.stdout.isatty():
|
# TODO clean up this ugly in sys.argv hack
|
||||||
|
if platform.system() == 'Windows' or not sys.stdout.isatty() or "--simple" in sys.argv:
|
||||||
obs = LoggingObserver()
|
obs = LoggingObserver()
|
||||||
else:
|
else:
|
||||||
obs = ProgressBarObserver(fd=sys.stdout)
|
obs = ProgressBarObserver(fd=sys.stdout)
|
||||||
|
|||||||
Reference in New Issue
Block a user