INNER CODE UNIT · Python

req

rignaneseleo/SlimSocial-for-Facebook · .github/scripts/crowdin_pretranslate.py:37

    req = urllib.request.Request(BASE + path, method=method, headers=headers, data=data)
    for attempt in range(4):
        try:
            with urllib.request.urlopen(req) as r:
                return json.load(r)
        except urllib.error.HTTPError as e:
            msg = e.read().decode()[:400]
            if e.code == 429 and attempt < 3:
                time.sleep(10)
                continue
            if any(s in msg for s in ok_errors):
                LAST_ERROR = msg
                print(f"note: {msg}")
                return None
            sys.exit(f"HTTP {e.code} on {method} {path}: {msg}")


files = api(f"/projects/{PROJECT_ID}/files?limit=100")["data"]

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…