Skip to content

Commit

Permalink
Merge pull request #47 from rolobio/44-sortable-output
Browse files Browse the repository at this point in the history
44 sortable output
  • Loading branch information
rolobio committed Aug 20, 2014
2 parents 5343bda + c26ce45 commit adedb99
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
5 changes: 1 addition & 4 deletions sshm/_info.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
#! /usr/bin/env python3

# This is the official version of sshm
__version__ = '1.0'
__version__ = '1.1'

__long_description__ = '''
SSH Multi v%s. SSH into multiple machines at once.
-p, --strip-whitespace Strip the whitespace surrounding any returned
data.
Examples:
Get a count of processes on each server:
sshm example1.com,example2.com,example3.com,mail[01-05].example.com,host[01-25].org "ps aux | wc -l"
Expand Down
10 changes: 9 additions & 1 deletion sshm/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ def get_argparse_args(args=None):
description=__long_description__)
parser.add_argument('servers')
parser.add_argument('command')
parser.add_argument('-p', '--strip-whitespace', action='store_true', default=False)
parser.add_argument('-s', '--sorted-output', action='store_true', default=False,
help='Sort the output by the URI of each instance. This will wait for all commands to finish before showing any output!')
parser.add_argument('-p', '--strip-whitespace', action='store_true', default=False,
help='Removing and whitespace surrounding the output of each instance.')
parser.add_argument('--version', action='version', version='%(prog)s '+__version__)
args, extra_args = parser.parse_known_args(args=args)
return (args, args.command, extra_args)
Expand Down Expand Up @@ -74,6 +77,11 @@ def main():

# Perform the command on each server, print the results to stdout.
results = sshm(args.servers, command, extra_arguments, stdin)
# If a sorted output is requested, gather all results before output.
if args.sorted_output:
results = list(results)
results = sorted(results, key=lambda x: x['uri'])

for result in results:
if result.get('stdout') != None:
_print_handling_newlines(result['uri'],
Expand Down

0 comments on commit adedb99

Please sign in to comment.