From 782aaef74ee46da9ec42c4e66d62afd3db403962 Mon Sep 17 00:00:00 2001 From: Olof-Joachim Frahm Date: Sat, 10 Jan 2015 21:12:13 +0000 Subject: [PATCH] Log directory creation. --- crypto-install.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/crypto-install.py b/crypto-install.py index 9715441..11e45eb 100755 --- a/crypto-install.py +++ b/crypto-install.py @@ -70,6 +70,14 @@ def parse_arguments (): return parser.parse_args () +def ensure_directories (path, mode = 0o777): + try: + os.makedirs (path, mode) + except OSError as exception: + if exception.errno != errno.EEXIST: + raise + + def gnupg_setup (arguments): gnupg_home = os.path.expanduser (arguments.gnupg_home) gnupg_secring = os.path.join (gnupg_home, "secring.gpg") @@ -92,6 +100,7 @@ def gnupg_setup (arguments): comment = read_input_string ("What is your comment phrase, if any (e.g. 'key for 2014')? ") if not os.path.exists (gnupg_home): + print ("Creating GnuPG directory at {!r}.".format (gnupg_home)) ensure_directories (gnupg_home, 0o700) with tempfile.NamedTemporaryFile () as tmp: @@ -123,21 +132,15 @@ def gnupg_setup (arguments): raise Exception ("Couldn't create GnuPG key.") -def ensure_directories (path, mode = 0o777): - try: - os.makedirs (path, mode) - except OSError as exception: - if exception.errno != errno.EEXIST: - raise - - def openssh_setup (arguments): openssh_home = os.path.expanduser (arguments.openssh_home) openssh_config = os.path.join (openssh_home, "config") if not os.path.exists (openssh_config): + print ("Creating OpenSSH directory at {!r}.".format (openssh_home)) ensure_directories (openssh_home, 0o700) + print ("Creating OpenSSH configuration at {!r}.".format (openssh_config)) with open (openssh_config, "w") as config: config.write (dedented (""" ForwardAgent yes @@ -147,7 +150,7 @@ def openssh_setup (arguments): openssh_key = os.path.join (openssh_home, "id_rsa") if os.path.exists (openssh_key): - print("OpenSSH key already exists at {!r}.".format (openssh_key)) + print ("OpenSSH key already exists at {!r}.".format (openssh_key)) return print (filled ("No OpenSSH key available. Generating new key.")) -- 1.7.10.4