mirror of
https://github.com/certbot/certbot.git
synced 2026-07-30 18:04:31 +02:00
Lint this entire monstrosity
- Doing some of @schoen's refactoring homework for him :)
This commit is contained in:
+10
-8
@@ -746,6 +746,8 @@ def _restore_required_config_elements(full_path, config, renewalparams):
|
|||||||
"a non-numeric value for %s. Skipping.",
|
"a non-numeric value for %s. Skipping.",
|
||||||
full_path, config_item)
|
full_path, config_item)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
def _restore_plugin_configs(config, renewalparams):
|
||||||
# Now use parser to get plugin-prefixed items with correct types
|
# Now use parser to get plugin-prefixed items with correct types
|
||||||
# XXX: the current approach of extracting only prefixed items
|
# XXX: the current approach of extracting only prefixed items
|
||||||
# related to the actually-used installer and authenticator
|
# related to the actually-used installer and authenticator
|
||||||
@@ -767,13 +769,12 @@ def _restore_required_config_elements(full_path, config, renewalparams):
|
|||||||
config.__setattr__(config_item, None)
|
config.__setattr__(config_item, None)
|
||||||
continue
|
continue
|
||||||
if config_item.startswith(plugin_prefix + "_"):
|
if config_item.startswith(plugin_prefix + "_"):
|
||||||
for action in _parser.parser._actions:
|
for action in _parser.parser._actions: # pylint: disable=protected-access
|
||||||
if action.dest == config_item:
|
if action.type is not None and action.dest == config_item:
|
||||||
if action.type is not None:
|
config.__setattr__(config_item, action.type(renewalparams[config_item]))
|
||||||
config.__setattr__(config_item, action.type(renewalparams[config_item]))
|
break
|
||||||
break
|
|
||||||
else:
|
else:
|
||||||
config.__setattr__(config_item, str(renewalparams[config_item]))
|
config.__setattr__(config_item, str(renewalparams[config_item]))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
@@ -808,6 +809,7 @@ def _reconstitute(full_path, config):
|
|||||||
# those elements are present.
|
# those elements are present.
|
||||||
try:
|
try:
|
||||||
_restore_required_config_elements(full_path, config, renewalparams)
|
_restore_required_config_elements(full_path, config, renewalparams)
|
||||||
|
_restore_plugin_configs(config, renewalparams)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
# There was a data type error which has already been
|
# There was a data type error which has already been
|
||||||
# logged.
|
# logged.
|
||||||
@@ -861,7 +863,7 @@ def renew(cli_config, plugins):
|
|||||||
# elements from within the renewal configuration file).
|
# elements from within the renewal configuration file).
|
||||||
try:
|
try:
|
||||||
renewal_candidate = _reconstitute(renewal_file, config)
|
renewal_candidate = _reconstitute(renewal_file, config)
|
||||||
except Exception as e:
|
except Exception as e: # pylint: disable=broad-except
|
||||||
# reconstitute encountered an unanticipated problem.
|
# reconstitute encountered an unanticipated problem.
|
||||||
logger.warning("Renewal configuration file %s produced an "
|
logger.warning("Renewal configuration file %s produced an "
|
||||||
"unexpected error: %s. Skipping.", renewal_file, e)
|
"unexpected error: %s. Skipping.", renewal_file, e)
|
||||||
@@ -1356,7 +1358,7 @@ def prepare_and_parse_args(plugins, args):
|
|||||||
# parser (--help should display plugin-specific options last)
|
# parser (--help should display plugin-specific options last)
|
||||||
_plugins_parsing(helpful, plugins)
|
_plugins_parsing(helpful, plugins)
|
||||||
|
|
||||||
global _parser
|
global _parser # pylint: disable=global-statement
|
||||||
_parser = helpful
|
_parser = helpful
|
||||||
return helpful.parse_args()
|
return helpful.parse_args()
|
||||||
|
|
||||||
|
|||||||
@@ -93,7 +93,6 @@ s.serve_forever()" """
|
|||||||
def prepare(self): # pylint: disable=missing-docstring,no-self-use
|
def prepare(self): # pylint: disable=missing-docstring,no-self-use
|
||||||
if self.config.noninteractive_mode:
|
if self.config.noninteractive_mode:
|
||||||
raise errors.PluginError("Running manual mode non-interactively is not supported")
|
raise errors.PluginError("Running manual mode non-interactively is not supported")
|
||||||
pass # pragma: no cover
|
|
||||||
|
|
||||||
def more_info(self): # pylint: disable=missing-docstring,no-self-use
|
def more_info(self): # pylint: disable=missing-docstring,no-self-use
|
||||||
return ("This plugin requires user's manual intervention in setting "
|
return ("This plugin requires user's manual intervention in setting "
|
||||||
|
|||||||
@@ -531,7 +531,8 @@ class CLITest(unittest.TestCase): # pylint: disable=too-many-public-methods
|
|||||||
self._certonly_new_request_common, mock_client)
|
self._certonly_new_request_common, mock_client)
|
||||||
|
|
||||||
def _test_renewal_common(self, due_for_renewal, extra_args, log_out=None,
|
def _test_renewal_common(self, due_for_renewal, extra_args, log_out=None,
|
||||||
args=None, renew=True, out=False):
|
args=None, renew=True):
|
||||||
|
# pylint: disable=too-many-locals
|
||||||
cert_path = 'letsencrypt/tests/testdata/cert.pem'
|
cert_path = 'letsencrypt/tests/testdata/cert.pem'
|
||||||
chain_path = '/etc/letsencrypt/live/foo.bar/fullchain.pem'
|
chain_path = '/etc/letsencrypt/live/foo.bar/fullchain.pem'
|
||||||
mock_lineage = mock.MagicMock(cert=cert_path, fullchain=chain_path)
|
mock_lineage = mock.MagicMock(cert=cert_path, fullchain=chain_path)
|
||||||
@@ -556,10 +557,7 @@ class CLITest(unittest.TestCase): # pylint: disable=too-many-public-methods
|
|||||||
args = ['-d', 'isnot.org', '-a', 'standalone', 'certonly']
|
args = ['-d', 'isnot.org', '-a', 'standalone', 'certonly']
|
||||||
if extra_args:
|
if extra_args:
|
||||||
args += extra_args
|
args += extra_args
|
||||||
if out:
|
self._call(args)
|
||||||
self._call_stdout(args)
|
|
||||||
else:
|
|
||||||
self._call(args)
|
|
||||||
|
|
||||||
if log_out:
|
if log_out:
|
||||||
with open(os.path.join(self.logs_dir, "letsencrypt.log")) as lf:
|
with open(os.path.join(self.logs_dir, "letsencrypt.log")) as lf:
|
||||||
|
|||||||
Reference in New Issue
Block a user