From a7611f3b46c69539473fba3c056d5002314299bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Asbj=C3=B8rn=20Sloth=20T=C3=B8nnesen?= Date: Thu, 7 Nov 2024 21:50:31 +0000 Subject: make domain name configurable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also change from peeringdb.com to www.peeringdb.com, so we don't have to get redirected on every request. Signed-off-by: Asbjørn Sloth Tønnesen --- sync.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'sync.py') diff --git a/sync.py b/sync.py index 8388d25..1450663 100755 --- a/sync.py +++ b/sync.py @@ -19,6 +19,7 @@ import logging from config import get_config schema_name = get_config().get('db_schemad', 'peeringdb') +domain_name = get_config().get('domain_name', 'www.peeringdb.com') #logging.basicConfig(level=logging.DEBUG) @@ -106,7 +107,7 @@ def last_updated(kind): return int(last) def fetch_objects(s, kind, extra_params): - endpoint = f'https://peeringdb.com/api/{kind:s}' + endpoint = f'https://{domain_name:s}/api/{kind:s}' params = { 'depth': 0, 'status__in': 'ok,pending,deleted', @@ -138,7 +139,7 @@ def initial_sync(s, kind): def sync_table(s, kind): test_table(kind) - endpoint = f'https://peeringdb.com/api/{kind:s}' + endpoint = f'https://{domain_name:s}/api/{kind:s}' last = last_updated(kind) if last is None: last = int(time.time()) - 3600 @@ -176,7 +177,7 @@ def main(): req_agent = s.headers.get('User-Agent') s.headers.update({'User-Agent': f'peeringdb-simplesync/0.1 {req_agent:s}'}) - spec_url = find_spec(s, 'https://peeringdb.com/apidocs/') + spec_url = find_spec(s, f'https://{domain_name:s}/apidocs/') s.headers.update({'Accept': 'application/x-yaml'}) r = s.get(spec_url) -- cgit v1.2.1