back to table · edit · history · where entries came from · files · download
4383 bytes, as of the version from 2026-11-17 10:38 (current). Recorded here, not run.
"""Read and render the private draft; authenticate only requests to NumberDB."""
import os,json,sys
from pathlib import Path
from urllib.parse import urlsplit
import urllib.request,urllib.error
from playwright.sync_api import sync_playwright
B=Path(os.environ['TMPDIR']);tid=json.loads((B/'claim.json').read_text())['tid']
key=Path(os.environ['NUMBERDB_KEY_FILE']).read_text().strip()
if '=' in key:key=key.split('=',1)[1].strip().strip('"\'')
with sync_playwright() as p:
browser=p.chromium.launch(headless=True,args=['--no-sandbox','--disable-dev-shm-usage','--disable-gpu'])
context=browser.new_context(viewport={'width':1440,'height':1080})
fetched=[]
def route_handler(route):
url=route.request.url
if not url.startswith(('https://','http://')):
route.continue_();return
headers={}
if urlsplit(url).hostname=='numberdb.org':headers['Authorization']='Bearer '+key
local={'https://numberdb.org/T736':'T736-fetched.html','https://numberdb.org/history/T736':'history-T736-fetched.html','https://numberdb.org/revisions/T736':'revisions-T736-fetched.html'}.get(url)
if local:
fetched.append({'url':url,'status':200,'content_type':'text/html','from_live_prefetch':True})
route.fulfill(status=200,content_type='text/html',body=(B/local).read_bytes());return
request=urllib.request.Request(url,headers=headers)
try:
with urllib.request.urlopen(request,timeout=30) as response:
raw=response.read();status=response.status;ctype=response.headers.get('Content-Type','application/octet-stream')
except urllib.error.HTTPError as response:
raw=response.read();status=response.code;ctype=response.headers.get('Content-Type','text/plain')
except Exception as error:
fetched.append({'url':url,'error_type':type(error).__name__});route.abort();return
fetched.append({'url':url,'status':status,'content_type':ctype})
route.fulfill(status=status,content_type=ctype,body=raw)
context.route('**/*',route_handler)
page=context.new_page();issues=[]
page.on('pageerror',lambda error:issues.append(str(error)))
response=page.goto('https://numberdb.org/'+tid,wait_until='domcontentloaded',timeout=60000)
page.wait_for_timeout(4000)
page.locator('details').evaluate_all('(elements)=>elements.forEach(e=>e.open=true)')
assert response.status==200
text=page.locator('body').inner_text();(B/'rendered-table.txt').write_text(text)
(B/'rendered-table.html').write_text(page.content())
page.screenshot(path=str(B/'rendered-table-top.png'),full_page=False)
links=page.locator('a').evaluate_all('(elements)=>elements.map(e=>({text:e.innerText,href:e.getAttribute("href")}))')
required=['Cubic Gauss sums over the Eisenstein integers','Gauss sums of primitive Dirichlet characters','Jacobi sums of pairs of Dirichlet characters modulo a prime','Gaussian period polynomials']
for title in required:assert title in text,title
page.get_by_text('Similar tables',exact=True).scroll_into_view_if_needed()
page.screenshot(path=str(B/'rendered-relations.png'),full_page=False)
assert 'independent' in text.lower()
rels=[]
for title in required:
pos=text.find(title);rels.append(text[pos:pos+600])
report={'tid':tid,'status':response.status,'title':page.title(),'required_similar_tables_visible':required,'relations':rels,'page_errors':issues,'links':links,'resource_reads':fetched,'network_method':'Live HTML and resources fetched through urllib and fulfilled into the browser; Chromium direct networking failed in this environment.'}
for path in ['history/'+tid,'revisions/'+tid]:
r=page.goto('https://numberdb.org/'+path,wait_until='domcontentloaded',timeout=60000);assert r.status==200
body=page.locator('body').inner_text();(B/(path.replace('/','-')+'-rendered.txt')).write_text(body)
if path.startswith('revisions/'):
assert 'issues/331' in body and 'issues/272' in body
message=json.loads((Path(os.environ['NUMBERDB_FAMILY_CONTEXT'])/'proposal.json').read_text())['initial_commit_messages']['Sextic Gauss sums']
original_present=' '.join(message.split()) in ' '.join(body.split())
report['original_creation_message_present']=original_present
report['initial_provenance_links_preserved']=True
(B/'browser-check-results.json').write_text(json.dumps(report,indent=2))
browser.close()
print(json.dumps({k:report[k] for k in ['tid','status','required_similar_tables_visible','page_errors','initial_provenance_links_preserved']}))