monkeysphere: yapf reformatting

Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Joseph Nuthalapati 2018-10-25 11:30:25 -07:00 committed by James Valleroy
parent 23110df2dd
commit f132b2ada9
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808

View File

@ -15,23 +15,23 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
""" """
Configuration helper for monkeysphere. Configuration helper for monkeysphere.
""" """
import argparse import argparse
import augeas
import contextlib import contextlib
import json import json
import os import os
import psutil
import re import re
import shutil import shutil
import signal import signal
import subprocess import subprocess
import tempfile import tempfile
import augeas
import psutil
def parse_arguments(): def parse_arguments():
"""Return parsed command line arguments as dictionary.""" """Return parsed command line arguments as dictionary."""
@ -40,20 +40,20 @@ def parse_arguments():
host_show_keys = subparsers.add_parser( host_show_keys = subparsers.add_parser(
'host-show-keys', help='Show imported/importable keys') 'host-show-keys', help='Show imported/importable keys')
host_show_keys.add_argument( host_show_keys.add_argument('key_id', nargs='?',
'key_id', nargs='?', help='Optional KEYID to retrieve details for') help='Optional KEYID to retrieve details for')
host_import_key = subparsers.add_parser( host_import_key = subparsers.add_parser(
'host-import-key', help='Import a key into monkeysphere') 'host-import-key', help='Import a key into monkeysphere')
host_import_key.add_argument( host_import_key.add_argument('ssh_fingerprint',
'ssh_fingerprint', help='SSH fingerprint of the key to import') help='SSH fingerprint of the key to import')
host_import_key.add_argument( host_import_key.add_argument('domains', nargs='*',
'domains', nargs='*', help='List of available domains') help='List of available domains')
host_publish_key = subparsers.add_parser( host_publish_key = subparsers.add_parser('host-publish-key',
'host-publish-key', help='Push host key to keyserver') help='Push host key to keyserver')
host_publish_key.add_argument( host_publish_key.add_argument('key_ids', nargs='*',
'key_ids', nargs='*', help='Optional list of KEYIDs') help='Optional list of KEYIDs')
host_cancel_publish = subparsers.add_parser( host_cancel_publish = subparsers.add_parser(
'host-cancel-publish', help='Cancel a running publish operation') 'host-cancel-publish', help='Cancel a running publish operation')
@ -72,10 +72,12 @@ def get_ssh_keys(fingerprint_hash):
output = subprocess.check_output( output = subprocess.check_output(
['ssh-keygen', '-l', '-E', fingerprint_hash, '-f', key_file]) ['ssh-keygen', '-l', '-E', fingerprint_hash, '-f', key_file])
fingerprint = output.decode().split()[1] fingerprint = output.decode().split()[1]
keys[fingerprint] = {'ssh_fingerprint': fingerprint, keys[fingerprint] = {
'service': 'ssh', 'ssh_fingerprint': fingerprint,
'key_file': key_file, 'service': 'ssh',
'available_domains': ['*']} 'key_file': key_file,
'available_domains': ['*']
}
return keys return keys
@ -188,7 +190,8 @@ def get_merged_keys(key_id=None):
if ssh_fingerprint in keys: if ssh_fingerprint in keys:
keys[ssh_fingerprint].update({ keys[ssh_fingerprint].update({
'available_domains': key['available_domains'], 'available_domains': key['available_domains'],
'key_file': key['key_file']}) 'key_file': key['key_file']
})
else: else:
keys[ssh_fingerprint] = key keys[ssh_fingerprint] = key
@ -253,10 +256,10 @@ def subcommand_host_import_key(arguments, second_run=False):
continue continue
env = dict(os.environ, MONKEYSPHERE_PROMPT='false') env = dict(os.environ, MONKEYSPHERE_PROMPT='false')
subprocess.check_call( subprocess.check_call([
['monkeysphere-host', 'add-servicename', 'monkeysphere-host', 'add-servicename',
key['service'] + '://' + domain, key['openpgp_fingerprint']], key['service'] + '://' + domain, key['openpgp_fingerprint']
env=env) ], env=env)
def subcommand_host_publish_key(arguments): def subcommand_host_publish_key(arguments):
@ -264,10 +267,8 @@ def subcommand_host_publish_key(arguments):
# setting TMPDIR as workaround for Debian bug #656750 # setting TMPDIR as workaround for Debian bug #656750
proc = subprocess.Popen( proc = subprocess.Popen(
['monkeysphere-host', 'publish-keys'] + arguments.key_ids, ['monkeysphere-host', 'publish-keys'] + arguments.key_ids,
stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=dict(
env=dict( os.environ, TMPDIR='/var/lib/monkeysphere/authentication/tmp/',
os.environ,
TMPDIR='/var/lib/monkeysphere/authentication/tmp/',
MONKEYSPHERE_PROMPT='false')) MONKEYSPHERE_PROMPT='false'))
output, error = proc.communicate() output, error = proc.communicate()
output, error = output.decode(), error.decode() output, error = output.decode(), error.decode()