mirror of
https://github.com/certbot/certbot.git
synced 2026-07-27 16:30:31 +02:00
Fix some PEP8 issues
This commit is contained in:
@@ -5,6 +5,7 @@ import smtplib
|
||||
import socket
|
||||
import subprocess
|
||||
|
||||
|
||||
def notify(subject, whom, what):
|
||||
"""Try to notify the addressee (whom) by e-mail, with Subject:
|
||||
defined by subject and message body by what."""
|
||||
|
||||
@@ -25,6 +25,7 @@ DEFAULTS["renewal_configs_dir"] = "/tmp/etc/letsencrypt/configs"
|
||||
DEFAULTS["official_archive_dir"] = "/tmp/etc/letsencrypt/archive"
|
||||
DEFAULTS["live_dir"] = "/tmp/etc/letsencrypt/live"
|
||||
|
||||
|
||||
class AttrDict(dict):
|
||||
"""A trick to allow accessing dictionary keys as object
|
||||
attributes."""
|
||||
@@ -32,16 +33,17 @@ class AttrDict(dict):
|
||||
super(AttrDict, self).__init__(*args, **kwargs)
|
||||
self.__dict__ = self
|
||||
|
||||
|
||||
def renew(cert, old_version):
|
||||
"""Perform automated renewal of the referenced cert, if possible."""
|
||||
# TODO: handle partial success
|
||||
# TODO: handle obligatory key rotation vs. optional key rotation vs.
|
||||
# requested key rotation
|
||||
if not cert.configfile.has_key("renewalparams"):
|
||||
if "renewalparams" not in cert.configfile:
|
||||
# TODO: notify user?
|
||||
return False
|
||||
renewalparams = cert.configfile["renewalparams"]
|
||||
if not renewalparams.has_key("authenticator"):
|
||||
if "authenticator" not in renewalparams:
|
||||
# TODO: notify user?
|
||||
return False
|
||||
# Instantiate the appropriate authenticator
|
||||
@@ -74,13 +76,14 @@ def renew(cert, old_version):
|
||||
# new_key if the old key is to be used (since save_successor
|
||||
# already understands this distinction!)
|
||||
return cert.save_successor(old_version, new_cert, new_key, new_chain)
|
||||
# TODO: Notify results
|
||||
# TODO: Notify results
|
||||
else:
|
||||
# TODO: Notify negative results
|
||||
# TODO: Notify negative results
|
||||
return False
|
||||
# TODO: Consider the case where the renewal was partially successful
|
||||
# (where fewer than all names were renewed)
|
||||
|
||||
|
||||
def main(config=DEFAULTS):
|
||||
"""main function for autorenewer script."""
|
||||
# TODO: Distinguish automated invocation from manual invocation,
|
||||
|
||||
@@ -21,6 +21,7 @@ DEFAULTS["official_archive_dir"] = "/tmp/etc/letsencrypt/archive"
|
||||
DEFAULTS["live_dir"] = "/tmp/etc/letsencrypt/live"
|
||||
ALL_FOUR = ("cert", "privkey", "chain", "fullchain")
|
||||
|
||||
|
||||
def parse_time_interval(interval, textparser=parsedatetime.Calendar()):
|
||||
"""Parse the time specified time interval, which can be in the
|
||||
English-language format understood by parsedatetime, e.g., '10 days',
|
||||
@@ -33,6 +34,7 @@ def parse_time_interval(interval, textparser=parsedatetime.Calendar()):
|
||||
return datetime.timedelta(0, time.mktime(textparser.parse(
|
||||
interval, time.localtime(0))[0]))
|
||||
|
||||
|
||||
class RenewableCert(object): # pylint: disable=too-many-instance-attributes
|
||||
"""Represents a lineage of certificates that is under the management
|
||||
of the Let's Encrypt client, indicated by the existence of an
|
||||
@@ -55,7 +57,7 @@ class RenewableCert(object): # pylint: disable=too-many-instance-attributes
|
||||
self.configuration = copy.deepcopy(defaults)
|
||||
self.configuration.merge(self.configfile)
|
||||
|
||||
if not all(self.configuration.has_key(x) for x in ALL_FOUR):
|
||||
if not all(x in self.configuration for x in ALL_FOUR):
|
||||
raise ValueError("renewal config file {0} is missing a required "
|
||||
"file reference".format(configfile))
|
||||
|
||||
@@ -244,7 +246,7 @@ class RenewableCert(object): # pylint: disable=too-many-instance-attributes
|
||||
pem)
|
||||
i = method(x509)
|
||||
return pyrfc3339.parse(i[0:4] + "-" + i[4:6] + "-" + i[6:8] + "T" +
|
||||
i[8:10] + ":" + i[10:12] +":" +i[12:])
|
||||
i[8:10] + ":" + i[10:12] + ":" + i[12:])
|
||||
|
||||
def notbefore(self, version=None):
|
||||
"""When is the beginning validity time of the specified version of the
|
||||
@@ -264,7 +266,7 @@ class RenewableCert(object): # pylint: disable=too-many-instance-attributes
|
||||
autodeployment is enabled, whether a relevant newer version
|
||||
exists, and whether the time interval for autodeployment has
|
||||
been reached.)"""
|
||||
if (not self.configuration.has_key("autodeploy") or
|
||||
if ("autodeploy" not in self.configuration or
|
||||
self.configuration.as_bool("autodeploy")):
|
||||
if self.has_pending_deployment():
|
||||
interval = self.configuration.get("deploy_before_expiry",
|
||||
@@ -291,7 +293,7 @@ class RenewableCert(object): # pylint: disable=too-many-instance-attributes
|
||||
def should_autorenew(self):
|
||||
"""Should an attempt be made to automatically renew the most
|
||||
recent certificate in this certificate lineage right now?"""
|
||||
if (not self.configuration.has_key("autorenew")
|
||||
if ("autorenew" not in self.configuration
|
||||
or self.configuration.as_bool("autorenew")):
|
||||
# Consider whether to attempt to autorenew this cert now
|
||||
# XXX: both self.ocsp_revoked() and self.notafter() are bugs
|
||||
|
||||
Reference in New Issue
Block a user