diff options
author | Asbjørn Sloth Tønnesen <ast@a5n.dk> | 2024-11-07 21:50:31 +0000 |
---|---|---|
committer | Asbjørn Sloth Tønnesen <ast@a5n.dk> | 2024-11-07 21:50:31 +0000 |
commit | a7611f3b46c69539473fba3c056d5002314299bc (patch) | |
tree | 1f1c5e90b6d9c01652dc32eb6dfefe92ee1a3357 /sync.py | |
parent | 1f5cebcc57313ecc446929af90a6383f91edbf4f (diff) | |
download | peeringdb-simplesync-a7611f3b46c69539473fba3c056d5002314299bc.tar.gz peeringdb-simplesync-a7611f3b46c69539473fba3c056d5002314299bc.tar.xz peeringdb-simplesync-a7611f3b46c69539473fba3c056d5002314299bc.zip |
make domain name configurable
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 <ast@a5n.dk>
Diffstat (limited to 'sync.py')
-rwxr-xr-x | sync.py | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -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) |