ConfiguratorError -> PluginError

This commit is contained in:
James Kasten 2015-06-26 09:29:40 -07:00
parent 36161c306a
commit 93a9a8b268
7 changed files with 36 additions and 36 deletions

View file

@ -397,7 +397,7 @@ class Client(object):
for dom in domains:
try:
self.installer.enhance(dom, "redirect")
except errors.ConfiguratorError:
except errors.PluginError:
logger.warn("Unable to perform redirect for %s", dom)
self.installer.save("Add Redirects")

View file

@ -46,16 +46,16 @@ class DvsniError(DvAuthError):
"""Let's Encrypt DVSNI error."""
# Configurator Errors
class ConfiguratorError(Error):
"""Let's Encrypt Configurator error."""
# Plugin Errors
class PluginError(Error):
"""Let's Encrypt Plugin error."""
class NoInstallationError(ConfiguratorError):
class NoInstallationError(PluginError):
"""Let's Encrypt No Installation error."""
class MisconfigurationError(ConfiguratorError):
class MisconfigurationError(PluginError):
"""Let's Encrypt Misconfiguration error."""

View file

@ -229,7 +229,7 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
:returns: ssl vhost associated with name
:rtype: :class:`~letsencrypt_apache.obj.VirtualHost`
:raises .errors.ConfiguratorError: If no vhost is available
:raises .errors.PluginError: If no vhost is available
"""
# Allows for domain names to be associated with a virtual host
@ -264,7 +264,7 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
"No vhost exists with servername or alias of: %s. "
"No vhost was selected. Please specify servernames "
"in the Apache config", target_name)
raise errors.ConfiguratorError("No vhost selected")
raise errors.PluginError("No vhost selected")
# TODO: Ask the user if they would like to add ServerName/Alias to VH
@ -479,7 +479,7 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
:returns: SSL vhost
:rtype: :class:`~letsencrypt_apache.obj.VirtualHost`
:raises .errors.ConfiguratorError: If more than one virtual host is in
:raises .errors.PluginError: If more than one virtual host is in
the file.
"""
@ -526,7 +526,7 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
(ssl_fp, parser.case_i("VirtualHost")))
if len(vh_p) != 1:
logger.error("Error: should only be one vhost in %s", avail_fp)
raise errors.ConfiguratorError("Only one vhost per file is allowed")
raise errors.PluginError("Only one vhost per file is allowed")
self.parser.add_dir(vh_p[0], "SSLCertificateFile",
"/etc/ssl/certs/ssl-cert-snakeoil.pem")
@ -581,9 +581,9 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
return self._enhance_func[enhancement](
self.choose_vhost(domain), options)
except ValueError:
raise errors.ConfiguratorError(
raise errors.PluginError(
"Unsupported enhancement: {}".format(enhancement))
except errors.ConfiguratorError:
except errors.PluginError:
logger.warn("Failed %s for %s", enhancement, domain)
def _enable_redirect(self, ssl_vhost, unused_options):
@ -629,7 +629,7 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
return
else:
logger.info("Unknown redirect exists for this vhost")
raise errors.ConfiguratorError(
raise errors.PluginError(
"Unknown redirect already exists "
"in {}".format(general_v.filep))
# Add directives to server
@ -700,7 +700,7 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
# Make sure adding the vhost will be safe
conflict, host_or_addrs = self._conflicting_host(ssl_vhost)
if conflict:
raise errors.ConfiguratorError(
raise errors.PluginError(
"Unable to create a redirection vhost - {}".format(
host_or_addrs))
@ -960,7 +960,7 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
except (OSError, ValueError):
logger.error(
"Error accessing %s for loaded modules!", self.conf("ctl"))
raise errors.ConfiguratorError("Error accessing loaded modules")
raise errors.PluginError("Error accessing loaded modules")
# Small errors that do not impede
if proc.returncode != 0:
logger.warn("Error in checking loaded module list: %s", stderr)
@ -1029,7 +1029,7 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
:returns: version
:rtype: tuple
:raises .ConfiguratorError: if unable to find Apache version
:raises .PluginError: if unable to find Apache version
"""
try:
@ -1039,14 +1039,14 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
stderr=subprocess.PIPE)
text = proc.communicate()[0]
except (OSError, ValueError):
raise errors.ConfiguratorError(
raise errors.PluginError(
"Unable to run %s -v" % self.conf("ctl"))
regex = re.compile(r"Apache/([0-9\.]*)", re.IGNORECASE)
matches = regex.findall(text)
if len(matches) != 1:
raise errors.ConfiguratorError("Unable to find Apache version")
raise errors.PluginError("Unable to find Apache version")
return tuple([int(i) for i in matches[0].split(".")])

View file

@ -196,14 +196,14 @@ class TwoVhost80Test(util.ApacheTest):
mock_popen().communicate.return_value = (
"Server Version: Apache (Debian)", "")
self.assertRaises(errors.ConfiguratorError, self.config.get_version)
self.assertRaises(errors.PluginError, self.config.get_version)
mock_popen().communicate.return_value = (
"Server Version: Apache/2.3{0} Apache/2.4.7".format(os.linesep), "")
self.assertRaises(errors.ConfiguratorError, self.config.get_version)
self.assertRaises(errors.PluginError, self.config.get_version)
mock_popen.side_effect = OSError("Can't find program")
self.assertRaises(errors.ConfiguratorError, self.config.get_version)
self.assertRaises(errors.PluginError, self.config.get_version)
if __name__ == "__main__":

View file

@ -112,7 +112,7 @@ class ApacheParserTest(util.ApacheTest):
mock_path.isfile.return_value = False
# pylint: disable=protected-access
self.assertRaises(errors.ConfiguratorError,
self.assertRaises(errors.PluginError,
self.parser._set_locations, self.ssl_options)
mock_path.isfile.side_effect = [True, False, False]

View file

@ -320,9 +320,9 @@ class NginxConfigurator(common.Plugin):
return self._enhance_func[enhancement](
self.choose_vhost(domain), options)
except (KeyError, ValueError):
raise errors.ConfiguratorError(
raise errors.PluginError(
"Unsupported enhancement: {0}".format(enhancement))
except errors.ConfiguratorError:
except errors.PluginError:
logger.warn("Failed %s for %s", enhancement, domain)
######################################
@ -385,7 +385,7 @@ class NginxConfigurator(common.Plugin):
:returns: version
:rtype: tuple
:raises .ConfiguratorError:
:raises .PluginError:
Unable to find Nginx version or version is unsupported
"""
@ -396,7 +396,7 @@ class NginxConfigurator(common.Plugin):
stderr=subprocess.PIPE)
text = proc.communicate()[1] # nginx prints output to stderr
except (OSError, ValueError):
raise errors.ConfiguratorError(
raise errors.PluginError(
"Unable to run %s -V" % self.conf('ctl'))
version_regex = re.compile(r"nginx/([0-9\.]*)", re.IGNORECASE)
@ -409,19 +409,19 @@ class NginxConfigurator(common.Plugin):
ssl_matches = ssl_regex.findall(text)
if not version_matches:
raise errors.ConfiguratorError("Unable to find Nginx version")
raise errors.PluginError("Unable to find Nginx version")
if not ssl_matches:
raise errors.ConfiguratorError(
raise errors.PluginError(
"Nginx build is missing SSL module (--with-http_ssl_module).")
if not sni_matches:
raise errors.ConfiguratorError("Nginx build doesn't support SNI")
raise errors.PluginError("Nginx build doesn't support SNI")
nginx_version = tuple([int(i) for i in version_matches[0].split(".")])
# nginx < 0.8.48 uses machine hostname as default server_name instead of
# the empty string
if nginx_version < (0, 8, 48):
raise errors.ConfiguratorError("Nginx version must be 0.8.48+")
raise errors.PluginError("Nginx version must be 0.8.48+")
return nginx_version

View file

@ -45,7 +45,7 @@ class NginxConfiguratorTest(util.NginxTest):
def test_enhance(self):
self.assertRaises(
errors.ConfiguratorError, self.config.enhance, 'myhost', 'redirect')
errors.PluginError, self.config.enhance, 'myhost', 'redirect')
def test_get_chall_pref(self):
self.assertEqual([challenges.DVSNI],
@ -215,19 +215,19 @@ class NginxConfiguratorTest(util.NginxTest):
" (based on LLVM 3.5svn)",
"TLS SNI support enabled",
"configure arguments: --with-http_ssl_module"]))
self.assertRaises(errors.ConfiguratorError, self.config.get_version)
self.assertRaises(errors.PluginError, self.config.get_version)
mock_popen().communicate.return_value = (
"", "\n".join(["nginx version: nginx/1.4.2",
"TLS SNI support enabled"]))
self.assertRaises(errors.ConfiguratorError, self.config.get_version)
self.assertRaises(errors.PluginError, self.config.get_version)
mock_popen().communicate.return_value = (
"", "\n".join(["nginx version: nginx/1.4.2",
"built by clang 6.0 (clang-600.0.56)"
" (based on LLVM 3.5svn)",
"configure arguments: --with-http_ssl_module"]))
self.assertRaises(errors.ConfiguratorError, self.config.get_version)
self.assertRaises(errors.PluginError, self.config.get_version)
mock_popen().communicate.return_value = (
"", "\n".join(["nginx version: nginx/0.8.1",
@ -235,10 +235,10 @@ class NginxConfiguratorTest(util.NginxTest):
" (based on LLVM 3.5svn)",
"TLS SNI support enabled",
"configure arguments: --with-http_ssl_module"]))
self.assertRaises(errors.ConfiguratorError, self.config.get_version)
self.assertRaises(errors.PluginError, self.config.get_version)
mock_popen.side_effect = OSError("Can't find program")
self.assertRaises(errors.ConfiguratorError, self.config.get_version)
self.assertRaises(errors.PluginError, self.config.get_version)
@mock.patch("letsencrypt_nginx.configurator.subprocess.Popen")
def test_nginx_restart(self, mock_popen):