Merge branch 'master' of github.com:unit3/crussh

This commit is contained in:
Graeme Humphries 2012-03-21 15:54:21 -07:00
commit 634e514a6c
2 changed files with 13 additions and 10 deletions

View File

@ -30,7 +30,7 @@ Install
The install process is very simple on most distros: The install process is very simple on most distros:
- Install python2, python-gtk2, and python-vte. - Install python2, python-gtk2, and python-vte.
- Run ./crussh.py hostname [hostname ...] - Run ./crussh.py HOST [HOST ...]
Bugs & TODO Bugs & TODO
----------- -----------

View File

@ -267,7 +267,7 @@ class CruSSH:
# give EntryBox default focus on init # give EntryBox default focus on init
self.EntryBox.props.has_focus = True self.EntryBox.props.has_focus = True
def __init__(self, hosts, ssh_args=None): def __init__(self, hosts, ssh_cmd="/usr/bin/ssh", ssh_args=None):
# load existing config file, if present # load existing config file, if present
try: try:
# merge dicts to allow upgrade from old configs # merge dicts to allow upgrade from old configs
@ -281,7 +281,7 @@ class CruSSH:
terminal = vte.Terminal() terminal = vte.Terminal()
# TODO: disable only this terminal widget on child exit # TODO: disable only this terminal widget on child exit
# v.connect("child-exited", lambda term: gtk.main_quit()) # v.connect("child-exited", lambda term: gtk.main_quit())
cmd_str = "/usr/bin/ssh" cmd_str = ssh_cmd
if ssh_args is not None: if ssh_args is not None:
cmd_str += " " + ssh_args cmd_str += " " + ssh_args
cmd_str += " " + host cmd_str += " " + host
@ -302,22 +302,25 @@ if __name__ == "__main__":
### Parse CLI Args ### ### Parse CLI Args ###
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(
description="Connect to multiple servers in parallel.", description="Connect to multiple hosts in parallel.",
usage="%(prog)s [OPTIONS] [--] HOST [HOST ...]", usage="%(prog)s [OPTIONS] [--] HOST [HOST ...]",
epilog="* NOTE: You can pass options to ssh if you add '--' before your list of hosts") epilog="* NOTE: You can pass options to ssh if you add '--' before your list of hosts")
parser.add_argument("--ssh", dest='ssh', default="/usr/bin/ssh",
help="specify the SSH executable to use (default: %(default)s)")
(args, hosts) = parser.parse_known_args() (args, hosts) = parser.parse_known_args()
if len(hosts) == 0: if len(hosts) == 0:
parser.print_usage() parser.print_usage()
parser.exit(2) parser.exit(2)
if "--" in hosts: try:
offset = hosts.index("--") + 1 offset = hosts.index("--")
ssh_args = " ".join(hosts[0:offset]) except:
hosts = hosts[offset:]
else:
ssh_args = None ssh_args = None
else:
ssh_args = " ".join(hosts[0:offset])
hosts = hosts[offset + 1:]
### Start Execution ### ### Start Execution ###
crussh = CruSSH(hosts, ssh_args) crussh = CruSSH(hosts, args.ssh, ssh_args)
gtk.main() gtk.main()