implementation of the issue #37
This commit is contained in:
parent
54c2264722
commit
6fcec3cdd7
29
timmy/cli.py
29
timmy/cli.py
@ -33,6 +33,7 @@ def pretty_run(quiet, msg, f, args=[], kwargs={}):
|
|||||||
print('%s: done' % msg)
|
print('%s: done' % msg)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
def parse_args():
|
def parse_args():
|
||||||
parser = argparse.ArgumentParser(description=('Parallel remote command'
|
parser = argparse.ArgumentParser(description=('Parallel remote command'
|
||||||
' execution and file'
|
' execution and file'
|
||||||
@ -107,7 +108,8 @@ def parse_args():
|
|||||||
parser.add_argument('-q', '--quiet',
|
parser.add_argument('-q', '--quiet',
|
||||||
help=('Print only command execution results and log'
|
help=('Print only command execution results and log'
|
||||||
' messages. Good for quick runs / "watch" wrap.'
|
' messages. Good for quick runs / "watch" wrap.'
|
||||||
' Also sets default loglevel to ERROR.'),
|
' Also sets default loglevel to ERROR.'
|
||||||
|
'This option disables any -v parameters.'),
|
||||||
action='store_true')
|
action='store_true')
|
||||||
parser.add_argument('-m', '--maxthreads', type=int, default=100,
|
parser.add_argument('-m', '--maxthreads', type=int, default=100,
|
||||||
help=('Maximum simultaneous nodes for command'
|
help=('Maximum simultaneous nodes for command'
|
||||||
@ -128,15 +130,12 @@ def parse_args():
|
|||||||
' results. Do not forget to clean up the results'
|
' results. Do not forget to clean up the results'
|
||||||
' manually when using this option.',
|
' manually when using this option.',
|
||||||
action='store_true')
|
action='store_true')
|
||||||
parser.add_argument('-w', '--warning',
|
parser.add_argument('-v', '--verbose', action='count', default=0,
|
||||||
help='Sets log level to warning (default).',
|
help=('This works for -vvvv, -vvv, -vv, -v, -v -v,'
|
||||||
action='store_true')
|
'etc, If no -v then logging.WARNING is '
|
||||||
parser.add_argument('-v', '--verbose',
|
'selected if more -v are provided it will '
|
||||||
help='Be verbose.',
|
'step to INFO and DEBUG unless the option '
|
||||||
action='store_true')
|
'-q(--quiet) is specified'))
|
||||||
parser.add_argument('-d', '--debug',
|
|
||||||
help='Be extremely verbose.',
|
|
||||||
action='store_true')
|
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
|
||||||
@ -146,14 +145,10 @@ def main(argv=None):
|
|||||||
argv = sys.argv
|
argv = sys.argv
|
||||||
parser = parse_args()
|
parser = parse_args()
|
||||||
args = parser.parse_args(argv[1:])
|
args = parser.parse_args(argv[1:])
|
||||||
if args.quiet and not args.warning:
|
loglevels = [logging.WARNING, logging.INFO, logging.DEBUG]
|
||||||
|
loglevel = loglevels[min(len(loglevels)-1, args.verbose)]
|
||||||
|
if args.quiet:
|
||||||
loglevel = logging.ERROR
|
loglevel = logging.ERROR
|
||||||
else:
|
|
||||||
loglevel = logging.WARNING
|
|
||||||
if args.verbose:
|
|
||||||
loglevel = logging.INFO
|
|
||||||
if args.debug:
|
|
||||||
loglevel = logging.DEBUG
|
|
||||||
logging.basicConfig(filename=args.log_file,
|
logging.basicConfig(filename=args.log_file,
|
||||||
level=loglevel,
|
level=loglevel,
|
||||||
format='%(asctime)s %(levelname)s %(message)s')
|
format='%(asctime)s %(levelname)s %(message)s')
|
||||||
|
@ -3,4 +3,3 @@ version = '1.3.0'
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user