diff --git a/home/bin/cssh b/home/bin/cssh index dbe2615..e7549b2 100755 --- a/home/bin/cssh +++ b/home/bin/cssh @@ -451,7 +451,7 @@ def parse_ssh_config(ssh_config_file_path) -> SshConfig: def main(): - logging.basicConfig(level=logging.DEBUG) + logging.basicConfig(level=logging.INFO) arg_parser = argparse.ArgumentParser('cssh (colored ssh) opens a terminal window with a background color that depends on the fully qualified domain name of the target machine') arg_parser.add_argument('ssh_target', help='eg root@alambix50.ipr.univ-rennes.fr') args = arg_parser.parse_args() @@ -459,15 +459,16 @@ def main(): ssh_target = SshTarget(args.ssh_target) # eg 'root@alambix50.ipr.univ-rennes.fr' ssh_config_file_path: Path = Path(os.getenv('HOME')) / '.ssh' / 'config' - host_real_name = ssh_target.host_id + host_real_name = None if ssh_config_file_path.exists(): ssh_config = parse_ssh_config(ssh_config_file_path) hn = ssh_config.get_host_name(ssh_target.host_id) if hn: host_real_name = hn + if host_real_name is None: + host_real_name = get_host_real_fqdn(ssh_target.host_id) logging.debug('host_real_name = %s', host_real_name) - ssh_target.host_id = get_host_real_fqdn(host_real_name) logging.debug('ssh_target.host_id = %s', ssh_target.host_id) # AS_ROOT='false' # if [ "$(echo $@ | grep '^root@' > /dev/null)" ] @@ -512,7 +513,7 @@ def main(): else: raise NotImplementedError(f'unhandled os : "{os_name}"') - proc = subprocess.run(['make_color.py', ssh_target.host_id, str(color_value), str(color_saturation), 'linux'], check=True, stdout=subprocess.PIPE) + proc = subprocess.run(['make_color.py', host_real_name, str(color_value), str(color_saturation), 'linux'], check=True, stdout=subprocess.PIPE) bg_color_as_str = proc.stdout.decode('utf8').strip() match = re.match(r'\((?P[0-9]+), (?P[0-9]+), (?P[0-9]+)\)', bg_color_as_str) assert match, f'unexpected color as string: {bg_color_as_str}'