INNER CODE UNIT · Python

request_json

1186258278/OpenClawChineseTranslation · scripts/verify-container-images.py:20

def request_json(url, token=None):
    headers = {'Accept': ACCEPT, 'User-Agent': 'openclaw-image-readback'}
    if token:
        headers['Authorization'] = f'Bearer {token}'
    # Only public anonymous pull tokens are used. Never read docker/gh login state.
    for attempt in range(3):
        try:
            with urllib.request.urlopen(urllib.request.Request(url, headers=headers), timeout=40) as response:
                data = response.read()
                return json.loads(data), 'sha256:' + hashlib.sha256(data).hexdigest()
        except (OSError, ValueError):
            if attempt == 2:
                raise
            time.sleep(2 ** attempt)


def validate_config(config, expected_version):
    runtime = config.get('config', {})

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…