From f0606a08799663f12f7999945980dc1df06fe048 Mon Sep 17 00:00:00 2001 From: mia Date: Tue, 30 Jul 2024 12:58:25 -0700 Subject: replace requests with httpx --- PKGBUILD | 6 +++--- pyproject.toml | 4 ++-- zoner.py | 12 ++++++------ 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/PKGBUILD b/PKGBUILD index 0ca8b12..61492ba 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -1,9 +1,9 @@ pkgname=zoner -pkgver=1 -pkgrel=2 +pkgver=2 +pkgrel=1 arch=(any) makedepends=(python-build python-installer python-wheel) -depends=(python-requests) +depends=(python-httpx) source=(pyproject.toml zoner.py compdef.zsh) sha256sums=(SKIP SKIP SKIP) license=(MIT) diff --git a/pyproject.toml b/pyproject.toml index 98d75e4..0b4d932 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "zoner" -version = "1" -dependencies = ["requests"] +version = "2" +dependencies = ["httpx"] [project.scripts] zoner = "zoner:main" diff --git a/zoner.py b/zoner.py index f4d4b1c..7772384 100644 --- a/zoner.py +++ b/zoner.py @@ -1,7 +1,7 @@ from pathlib import Path import tomllib import os -import requests +import httpx import subprocess import sys @@ -78,15 +78,15 @@ def update_rules(rules: dict, statement: str): raise ValueError(f"invalid rule {key}") -def check_porkbun(resp: requests.Response): +def check_porkbun(resp: httpx.Response): if resp.status_code >= 400: - raise requests.HTTPError( + raise httpx.HTTPError( f"got code {resp.status_code}: {resp.json()}", response=resp ) def retrieve(domain: str): - resp = requests.post( + resp = httpx.post( f"https://porkbun.com/api/json/v3/dns/retrieve/{domain}", json={"apikey": cfg["api_key"], "secretapikey": cfg["secret_key"]}, ) @@ -156,7 +156,7 @@ def balance(domain: str): for record in to_delete: print(f"delete {record}") - resp = requests.post( + resp = httpx.post( f"https://porkbun.com/api/json/v3/dns/delete/{domain}/{record.meta['id']}", json={"apikey": cfg["api_key"], "secretapikey": cfg["secret_key"]}, ) @@ -168,7 +168,7 @@ def balance(domain: str): prio = None if record.kind == "MX": prio, content = content.split(" ") - resp = requests.post( + resp = httpx.post( f"https://porkbun.com/api/json/v3/dns/create/{domain}", json={ "apikey": cfg["api_key"], -- cgit 1.4.1