chore: improve type annotations
This commit is contained in:
parent
52fa7292aa
commit
5fad1f8ebe
3 changed files with 7 additions and 9 deletions
|
@ -11,7 +11,7 @@ from .config import read_config
|
||||||
logging.basicConfig(level=logging.INFO, format='[%(levelname)s] %(name)s: %(message)s')
|
logging.basicConfig(level=logging.INFO, format='[%(levelname)s] %(name)s: %(message)s')
|
||||||
log = logging.getLogger('nyacme')
|
log = logging.getLogger('nyacme')
|
||||||
|
|
||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
prog='nyacme',
|
prog='nyacme',
|
||||||
|
@ -36,7 +36,7 @@ def main() -> None:
|
||||||
|
|
||||||
cert_path = output_dir / domain / 'cert.pem'
|
cert_path = output_dir / domain / 'cert.pem'
|
||||||
if cert_path.is_file():
|
if cert_path.is_file():
|
||||||
cmd = [ 'openssl', 'x509', '-enddate', '-noout', '-in', cert_path ]
|
cmd: list[str] = [ 'openssl', 'x509', '-enddate', '-noout', '-in', str(cert_path) ]
|
||||||
out = subprocess.run(cmd, stdout=subprocess.PIPE, check=True).stdout.decode('utf-8').strip()
|
out = subprocess.run(cmd, stdout=subprocess.PIPE, check=True).stdout.decode('utf-8').strip()
|
||||||
date = datetime.strptime(out, 'notAfter=%b %d %H:%M:%S %Y %Z')
|
date = datetime.strptime(out, 'notAfter=%b %d %H:%M:%S %Y %Z')
|
||||||
# if more than 1 month, skip
|
# if more than 1 month, skip
|
||||||
|
@ -86,8 +86,8 @@ def main() -> None:
|
||||||
all_key.hardlink_to(domain_key)
|
all_key.hardlink_to(domain_key)
|
||||||
|
|
||||||
if acquired:
|
if acquired:
|
||||||
for cmd in config.post_acquire:
|
for post_cmd in config.post_acquire:
|
||||||
subprocess.run(cmd, shell=True, check=True)
|
subprocess.run(post_cmd, shell=True, check=True)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import json
|
import json
|
||||||
import urllib.request
|
import urllib.request
|
||||||
from typing import Any, Optional
|
from typing import Any
|
||||||
|
|
||||||
from ..config import Config
|
from ..config import Config
|
||||||
from .base import Handler
|
from .base import Handler
|
||||||
|
@ -17,10 +17,8 @@ class PorkbunHandler(Handler):
|
||||||
|
|
||||||
self.nameservers = self.fetch(f'/domain/getNs/{self.zone}')['ns']
|
self.nameservers = self.fetch(f'/domain/getNs/{self.zone}')['ns']
|
||||||
|
|
||||||
def fetch(self, url: str, data: Optional[dict[str, Any]] = None) -> Any:
|
def fetch(self, url: str, data: dict[str, Any] = {}) -> Any:
|
||||||
req = urllib.request.Request('https://api.porkbun.com/api/json/v3' + url)
|
req = urllib.request.Request('https://api.porkbun.com/api/json/v3' + url)
|
||||||
if not data:
|
|
||||||
data = {}
|
|
||||||
|
|
||||||
data['apikey'] = self.apikey
|
data['apikey'] = self.apikey
|
||||||
data['secretapikey'] = self.secretapikey
|
data['secretapikey'] = self.secretapikey
|
||||||
|
|
|
@ -20,7 +20,7 @@ handlers = {
|
||||||
}
|
}
|
||||||
|
|
||||||
class Args:
|
class Args:
|
||||||
def __init__(self, argv):
|
def __init__(self, argv: list[str]) -> None:
|
||||||
# one of 'begin', 'done', 'failed'
|
# one of 'begin', 'done', 'failed'
|
||||||
self.method = argv[1]
|
self.method = argv[1]
|
||||||
# challenge type (dns-01, http-01 or tls-alpn-01)
|
# challenge type (dns-01, http-01 or tls-alpn-01)
|
||||||
|
|
Loading…
Reference in a new issue