mirror of
https://github.com/certbot/certbot.git
synced 2026-08-01 16:19:13 +02:00
Merge pull request #3269 from yan12125/python3-certonly
Python 3 support for certonly
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
"""ACME AuthHandler."""
|
"""ACME AuthHandler."""
|
||||||
import itertools
|
|
||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
import six
|
||||||
import zope.component
|
import zope.component
|
||||||
|
|
||||||
from acme import challenges
|
from acme import challenges
|
||||||
@@ -141,7 +141,7 @@ class AuthHandler(object):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
active_achalls = []
|
active_achalls = []
|
||||||
for achall, resp in itertools.izip(achalls, resps):
|
for achall, resp in six.moves.zip(achalls, resps):
|
||||||
# This line needs to be outside of the if block below to
|
# This line needs to be outside of the if block below to
|
||||||
# ensure failed challenges are cleaned up correctly
|
# ensure failed challenges are cleaned up correctly
|
||||||
active_achalls.append(achall)
|
active_achalls.append(achall)
|
||||||
@@ -472,7 +472,7 @@ def _report_failed_challs(failed_achalls):
|
|||||||
problems.setdefault(achall.error.typ, []).append(achall)
|
problems.setdefault(achall.error.typ, []).append(achall)
|
||||||
|
|
||||||
reporter = zope.component.getUtility(interfaces.IReporter)
|
reporter = zope.component.getUtility(interfaces.IReporter)
|
||||||
for achalls in problems.itervalues():
|
for achalls in six.itervalues(problems):
|
||||||
reporter.add_message(
|
reporter.add_message(
|
||||||
_generate_failed_chall_msg(achalls), reporter.MEDIUM_PRIORITY)
|
_generate_failed_chall_msg(achalls), reporter.MEDIUM_PRIORITY)
|
||||||
|
|
||||||
|
|||||||
+4
-2
@@ -343,8 +343,10 @@ class HelpfulArgumentParser(object):
|
|||||||
self.determine_verb()
|
self.determine_verb()
|
||||||
help1 = self.prescan_for_flag("-h", self.help_topics)
|
help1 = self.prescan_for_flag("-h", self.help_topics)
|
||||||
help2 = self.prescan_for_flag("--help", self.help_topics)
|
help2 = self.prescan_for_flag("--help", self.help_topics)
|
||||||
assert max(True, "a") == "a", "Gravity changed direction"
|
if isinstance(help1, bool) and isinstance(help2, bool):
|
||||||
self.help_arg = max(help1, help2)
|
self.help_arg = help1 or help2
|
||||||
|
else:
|
||||||
|
self.help_arg = help1 if isinstance(help1, str) else help2
|
||||||
if self.help_arg is True:
|
if self.help_arg is True:
|
||||||
# just --help with no topic; avoid argparse altogether
|
# just --help with no topic; avoid argparse altogether
|
||||||
print(usage)
|
print(usage)
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ CLI_DEFAULTS = dict(
|
|||||||
os.path.join(os.environ.get("XDG_CONFIG_HOME", "~/.config"),
|
os.path.join(os.environ.get("XDG_CONFIG_HOME", "~/.config"),
|
||||||
"letsencrypt", "cli.ini"),
|
"letsencrypt", "cli.ini"),
|
||||||
],
|
],
|
||||||
verbose_count=-(logging.INFO / 10),
|
verbose_count=-int(logging.INFO / 10),
|
||||||
server="https://acme-v01.api.letsencrypt.org/directory",
|
server="https://acme-v01.api.letsencrypt.org/directory",
|
||||||
rsa_key_size=2048,
|
rsa_key_size=2048,
|
||||||
rollback_checkpoints=1,
|
rollback_checkpoints=1,
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import collections
|
|||||||
import itertools
|
import itertools
|
||||||
import logging
|
import logging
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
|
import six
|
||||||
|
|
||||||
import zope.interface
|
import zope.interface
|
||||||
import zope.interface.verify
|
import zope.interface.verify
|
||||||
@@ -194,12 +195,12 @@ class PluginsRegistry(collections.Mapping):
|
|||||||
def init(self, config):
|
def init(self, config):
|
||||||
"""Initialize all plugins in the registry."""
|
"""Initialize all plugins in the registry."""
|
||||||
return [plugin_ep.init(config) for plugin_ep
|
return [plugin_ep.init(config) for plugin_ep
|
||||||
in self._plugins.itervalues()]
|
in six.itervalues(self._plugins)]
|
||||||
|
|
||||||
def filter(self, pred):
|
def filter(self, pred):
|
||||||
"""Filter plugins based on predicate."""
|
"""Filter plugins based on predicate."""
|
||||||
return type(self)(dict((name, plugin_ep) for name, plugin_ep
|
return type(self)(dict((name, plugin_ep) for name, plugin_ep
|
||||||
in self._plugins.iteritems() if pred(plugin_ep)))
|
in six.iteritems(self._plugins) if pred(plugin_ep)))
|
||||||
|
|
||||||
def visible(self):
|
def visible(self):
|
||||||
"""Filter plugins based on visibility."""
|
"""Filter plugins based on visibility."""
|
||||||
@@ -216,7 +217,7 @@ class PluginsRegistry(collections.Mapping):
|
|||||||
|
|
||||||
def prepare(self):
|
def prepare(self):
|
||||||
"""Prepare all plugins in the registry."""
|
"""Prepare all plugins in the registry."""
|
||||||
return [plugin_ep.prepare() for plugin_ep in self._plugins.itervalues()]
|
return [plugin_ep.prepare() for plugin_ep in six.itervalues(self._plugins)]
|
||||||
|
|
||||||
def available(self):
|
def available(self):
|
||||||
"""Filter plugins based on availability."""
|
"""Filter plugins based on availability."""
|
||||||
@@ -238,7 +239,7 @@ class PluginsRegistry(collections.Mapping):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
# use list instead of set because PluginEntryPoint is not hashable
|
# use list instead of set because PluginEntryPoint is not hashable
|
||||||
candidates = [plugin_ep for plugin_ep in self._plugins.itervalues()
|
candidates = [plugin_ep for plugin_ep in six.itervalues(self._plugins)
|
||||||
if plugin_ep.initialized and plugin_ep.init() is plugin]
|
if plugin_ep.initialized and plugin_ep.init() is plugin]
|
||||||
assert len(candidates) <= 1
|
assert len(candidates) <= 1
|
||||||
if candidates:
|
if candidates:
|
||||||
@@ -249,7 +250,7 @@ class PluginsRegistry(collections.Mapping):
|
|||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "{0}({1})".format(
|
return "{0}({1})".format(
|
||||||
self.__class__.__name__, ','.join(
|
self.__class__.__name__, ','.join(
|
||||||
repr(p_ep) for p_ep in self._plugins.itervalues()))
|
repr(p_ep) for p_ep in six.itervalues(self._plugins)))
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
if not self._plugins:
|
if not self._plugins:
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import sys
|
|||||||
import tempfile
|
import tempfile
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
import six
|
||||||
import zope.component
|
import zope.component
|
||||||
import zope.interface
|
import zope.interface
|
||||||
|
|
||||||
@@ -187,7 +188,7 @@ s.serve_forever()" """
|
|||||||
#answer = zope.component.getUtility(interfaces.IDisplay).notification(
|
#answer = zope.component.getUtility(interfaces.IDisplay).notification(
|
||||||
# message=message, height=25, pause=True)
|
# message=message, height=25, pause=True)
|
||||||
sys.stdout.write(message)
|
sys.stdout.write(message)
|
||||||
raw_input("Press ENTER to continue")
|
six.moves.input("Press ENTER to continue")
|
||||||
|
|
||||||
def cleanup(self, achalls):
|
def cleanup(self, achalls):
|
||||||
# pylint: disable=missing-docstring,no-self-use,unused-argument
|
# pylint: disable=missing-docstring,no-self-use,unused-argument
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ def pick_plugin(config, default, plugins, question, ifaces):
|
|||||||
else:
|
else:
|
||||||
return plugin_ep.init()
|
return plugin_ep.init()
|
||||||
elif len(prepared) == 1:
|
elif len(prepared) == 1:
|
||||||
plugin_ep = prepared.values()[0]
|
plugin_ep = list(prepared.values())[0]
|
||||||
logger.debug("Single candidate plugin: %s", plugin_ep)
|
logger.debug("Single candidate plugin: %s", plugin_ep)
|
||||||
if plugin_ep.misconfigured:
|
if plugin_ep.misconfigured:
|
||||||
return None
|
return None
|
||||||
|
|||||||
@@ -422,6 +422,9 @@ def enforce_domain_sanity(domain):
|
|||||||
else:
|
else:
|
||||||
raise errors.ConfigurationError(str(error_fmt).format(domain))
|
raise errors.ConfigurationError(str(error_fmt).format(domain))
|
||||||
|
|
||||||
|
if six.PY3:
|
||||||
|
domain = domain.decode('ascii')
|
||||||
|
|
||||||
# Remove trailing dot
|
# Remove trailing dot
|
||||||
domain = domain[:-1] if domain.endswith('.') else domain
|
domain = domain[:-1] if domain.endswith('.') else domain
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ install_requires = [
|
|||||||
'parsedatetime>=1.3', # Calendar.parseDT
|
'parsedatetime>=1.3', # Calendar.parseDT
|
||||||
'PyOpenSSL',
|
'PyOpenSSL',
|
||||||
'pyrfc3339',
|
'pyrfc3339',
|
||||||
'python2-pythondialog>=3.2.2rc1', # Debian squeeze support, cf. #280
|
|
||||||
'pytz',
|
'pytz',
|
||||||
# For pkg_resources. >=1.0 so pip resolves it to a version cryptography
|
# For pkg_resources. >=1.0 so pip resolves it to a version cryptography
|
||||||
# will tolerate; see #2599:
|
# will tolerate; see #2599:
|
||||||
@@ -52,6 +51,12 @@ install_requires = [
|
|||||||
'zope.interface',
|
'zope.interface',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# Debian squeeze support, cf. #280
|
||||||
|
if sys.version_info[0] == 2:
|
||||||
|
install_requires.append('python2-pythondialog>=3.2.2rc1')
|
||||||
|
else:
|
||||||
|
install_requires.append('pythondialog>=3.2.2rc1')
|
||||||
|
|
||||||
# env markers in extras_require cause problems with older pip: #517
|
# env markers in extras_require cause problems with older pip: #517
|
||||||
# Keep in sync with conditional_requirements.py.
|
# Keep in sync with conditional_requirements.py.
|
||||||
if sys.version_info < (2, 7):
|
if sys.version_info < (2, 7):
|
||||||
|
|||||||
Reference in New Issue
Block a user