Exemplo n.º 1
0
def diagnose_configurator_problem(cfg_type, requested, plugins):
    """
    Raise the most helpful error message about a plugin being unavailable

    :param str cfg_type: either "installer" or "authenticator"
    :param str requested: the plugin that was requested
    :param PluginRegistry plugins: available plugins

    :raises error.PluginSelectionError: if there was a problem
    """

    if requested:
        if requested not in plugins:
            msg = "The requested {0} plugin does not appear to be installed".format(
                requested)
        else:
            msg = ("The {0} plugin is not working; there may be problems with "
                   "your existing configuration").format(requested)
    elif cfg_type == "installer":
        if os.path.exists("/etc/debian_version"):
            # Debian... installers are at least possible
            msg = (
                'No installers seem to be present and working on your system; '
                'fix that or try running letsencrypt with the "auth" command')
        else:
            # XXX update this logic as we make progress on #788 and nginx support
            msg = (
                'No installers are available on your OS yet; try running '
                '"letsencrypt-auto auth" to get a cert you can install manually'
            )
    else:
        msg = "{0} could not be determined or is not installed".format(
            cfg_type)
    raise PluginSelectionError(msg)
Exemplo n.º 2
0
def set_configurator(previously, now):
    """
    Setting configurators multiple ways is okay, as long as they all agree
    :param str previously: previously identified request for the installer/authenticator
    :param str requested: the request currently being processed
    """
    if now is None:
        # we're not actually setting anything
        return previously
    if previously:
        if previously != now:
            msg = "Too many flags setting configurators/installers/authenticators {0} -> {1}"
            raise PluginSelectionError(msg.format(repr(previously), repr(now)))
    return now