Commit e9571142 authored by Adrien Dorsaz's avatar Adrien Dorsaz
Browse files

fix pylint and pycodestyle warnings

parent 66424408
Pipeline #314 passed with stages
in 15 minutes and 48 seconds
......@@ -92,7 +92,7 @@ def get_crt(config, log=LOGGER):
except ValueError: # if body is empty or not JSON formatted
return response, json.loads("{}")
else:
raise RuntimeError("Unable to get response from ACME server.")
raise RuntimeError("Unable to get response from ACME server.")
# main code
adtheaders = {'User-Agent': 'acme-dns-tiny/2.2',
......@@ -147,9 +147,9 @@ def get_crt(config, log=LOGGER):
accountkey = _openssl("rsa", ["-in", config["acmednstiny"]["AccountKeyFile"],
"-noout", "-text"])
signature_search = re.search(r"modulus:\s+?00:([a-f0-9\:\s]+?)\r?\npublicExponent: ([0-9]+)",
accountkey.decode("utf8"), re.MULTILINE)
accountkey.decode("utf8"), re.MULTILINE)
if signature_search is None:
raise ValueError("Unable to retrieve private signature.");
raise ValueError("Unable to retrieve private signature.")
pub_hex, pub_exp = signature_search.groups()
pub_exp = "{0:x}".format(int(pub_exp))
pub_exp = "0{0}".format(pub_exp) if len(pub_exp) % 2 else pub_exp
......
......@@ -30,6 +30,7 @@ def _openssl(command, options, communicate=None):
return out
# pylint: disable=too-many-statements
def account_deactivate(accountkeypath, acme_directory, log=LOGGER):
"""Deactivate an ACME account."""
......@@ -70,7 +71,7 @@ def account_deactivate(accountkeypath, acme_directory, log=LOGGER):
except ValueError: # if body is empty or not JSON formatted
return response, json.loads("{}")
else:
raise RuntimeError("Unable to get response from ACME server.")
raise RuntimeError("Unable to get response from ACME server.")
# main code
adtheaders = {'User-Agent': 'acme-dns-tiny/2.2'}
......@@ -82,9 +83,9 @@ def account_deactivate(accountkeypath, acme_directory, log=LOGGER):
log.info("Get private signature from account key.")
accountkey = _openssl("rsa", ["-in", accountkeypath, "-noout", "-text"])
signature_search = re.search(r"modulus:\s+?00:([a-f0-9\:\s]+?)\r?\npublicExponent: ([0-9]+)",
accountkey.decode("utf8"), re.MULTILINE)
accountkey.decode("utf8"), re.MULTILINE)
if signature_search is None:
raise ValueError("Unable to retrieve private signature.");
raise ValueError("Unable to retrieve private signature.")
pub_hex, pub_exp = signature_search.groups()
pub_exp = "{0:x}".format(int(pub_exp))
pub_exp = "0{0}".format(pub_exp) if len(pub_exp) % 2 else pub_exp
......
......@@ -36,10 +36,11 @@ def account_rollover(old_accountkeypath, new_accountkeypath, acme_directory, log
def _get_private_acme_signature(accountkeypath):
"""Read the account key to get the signature to authenticate with the ACME server."""
accountkey = _openssl("rsa", ["-in", accountkeypath, "-noout", "-text"])
signature_search = re.search(r"modulus:\s+?00:([a-f0-9\:\s]+?)\r?\npublicExponent: ([0-9]+)",
signature_search = re.search(
r"modulus:\s+?00:([a-f0-9\:\s]+?)\r?\npublicExponent: ([0-9]+)",
accountkey.decode("utf8"), re.MULTILINE)
if signature_search is None:
raise ValueError("Unable to retrieve private signature.");
raise ValueError("Unable to retrieve private signature.")
pub_hex, pub_exp = signature_search.groups()
pub_exp = "{0:x}".format(int(pub_exp))
pub_exp = "0{0}".format(pub_exp) if len(pub_exp) % 2 else pub_exp
......@@ -64,7 +65,7 @@ def account_rollover(old_accountkeypath, new_accountkeypath, acme_directory, log
elif keypath == old_accountkeypath:
protected = copy.deepcopy(private_acme_old_signature)
else:
raise RuntimeError("Unknown keypath to sign request")
raise RuntimeError("Unknown keypath to sign request")
if is_inner or url == acme_config["newAccount"]:
if "kid" in protected:
......@@ -103,7 +104,7 @@ def account_rollover(old_accountkeypath, new_accountkeypath, acme_directory, log
except ValueError: # if body is empty or not JSON formatted
return response, json.dumps({})
else:
raise RuntimeError("Unable to get response from ACME server.")
raise RuntimeError("Unable to get response from ACME server.")
# main code
adtheaders = {'User-Agent': 'acme-dns-tiny/2.2'}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment