Enable ssh login as the Python user for the current user

This command will create an authorized_keys file on the target device
containing the current users public key.  This will allow ssh to
the WVA from this machine.

def authorize(ctx, public_key, append):
    """Enable ssh login as the Python user for the current user

This command will create an authorized_keys file on the target device
containing the current users public key.  This will allow ssh to
the WVA from this machine.
"""
    wva = get_wva(ctx)

    http_client = wva.get_http_client()
    authorized_keys_uri = "/files/userfs/WEB/python/.ssh/authorized_keys"
    authorized_key_contents = public_key
    if append:
        try:
            existing_contents = http_client.get(authorized_keys_uri)
            authorized_key_contents = "{}\n{}".format(existing_contents, public_key)
        except WVAHttpNotFoundError:
            pass  # file doesn't exist, just write the public key
    http_client.put(authorized_keys_uri, authorized_key_contents)

    print("Public key written to authorized_keys for python user.")
    print("You should now be able to ssh to the device by doing the following:")
    print("")
    print("  $ ssh python@{}".format(get_root_ctx(ctx).hostname))