diff options
author | Jan Dittberner <jandd@cacert.org> | 2018-10-27 23:22:55 +0200 |
---|---|---|
committer | Jan Dittberner <jandd@cacert.org> | 2018-10-27 23:23:27 +0200 |
commit | 5c48baef28d0e7dc9a6de1eb58b0798ba913d9a9 (patch) | |
tree | aa2b6024c3719be4875b32ea46a26765f7d0bf1c /tools/ssh_host_keys.py | |
parent | 72493e64ef5ad7562678d2dc289fa6835faad8d6 (diff) | |
download | cacert-infradocs-5c48baef28d0e7dc9a6de1eb58b0798ba913d9a9.tar.gz cacert-infradocs-5c48baef28d0e7dc9a6de1eb58b0798ba913d9a9.tar.xz cacert-infradocs-5c48baef28d0e7dc9a6de1eb58b0798ba913d9a9.zip |
Port tools to Python 3
Diffstat (limited to 'tools/ssh_host_keys.py')
-rwxr-xr-x | tools/ssh_host_keys.py | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/tools/ssh_host_keys.py b/tools/ssh_host_keys.py index df0c45a..8d8eddd 100755 --- a/tools/ssh_host_keys.py +++ b/tools/ssh_host_keys.py @@ -1,19 +1,18 @@ #!/usr/bin/env python -from glob import glob import argparse import os.path import subprocess +from glob import glob - -SUPPORTED_SSH_KEYTYPES = ('RSA', 'DSA', 'ECDSA', 'ED25519') +SUPPORTED_SSH_KEY_TYPES = ('RSA', 'DSA', 'ECDSA', 'ED25519') if __name__ == '__main__': parser = argparse.ArgumentParser( description=( 'Convert a set of ssh host keys to the syntax expected by the ' - 'sshkeys directive of the CAcert infrastructur documentation')) + 'sshkeys directive of the CAcert infrastructure documentation')) parser.add_argument( 'root', metavar='ROOT', type=str, help='root directory' ) @@ -25,13 +24,14 @@ if __name__ == '__main__': ): fp = subprocess.check_output( ['ssh-keygen', '-l', '-f', host_key]).strip().split() - keys[fp[3][1:-1]] = fp[1] + keys[fp[3][1:-1].decode('ascii')] = fp[1].decode('ascii') - maxlen = max([len(key) for key in keys.keys() if key in SUPPORTED_SSH_KEYTYPES]) + max_length = max([len(key) for key in keys.keys() + if key in SUPPORTED_SSH_KEY_TYPES]) - print ".. sshkeys::" + print(".. sshkeys::") for typ, key in [ - (typ, keys[typ]) for typ in SUPPORTED_SSH_KEYTYPES + (typ, keys[typ]) for typ in SUPPORTED_SSH_KEY_TYPES if typ in keys ]: - print " :%s:%s %s" % (typ, ' ' * (maxlen - len(typ)), key) + print(" :{}:{} {}".format(typ, ' ' * (max_length - len(typ)), key)) |