a
    šþ’j)	  ã                   @   sf   d Z ddlZddlZddlZddlmZ edƒZed ZejZ	dd„ Z
dd	„ Zed
krbe eƒ ¡ dS )a"  Rebuild dashboard.html locally. No git, no upload.

WHY THIS EXISTS SEPARATELY FROM publish_dashboard.py. That script did two jobs:
it rebuilt the page (resolve_live_data.py, then dashboard.py --quiet) and then
pushed the result to GitHub Pages. The push is what got the account suspended,
so its scheduled task is disabled -- and disabling it silently took the REBUILD
with it, leaving the served page frozen at whatever it last wrote.

This is the rebuild half on its own. serve_dashboard.py shells out to it for the
Refresh button, and a scheduled task runs it periodically, so the two paths
cannot drift.

Exit codes: 0 built, 1 build failed. resolve_live_data failing is not fatal --
it only backfills results already present in the data file, and a stale result
column beats no dashboard at all.
é    N)ÚPathz	E:\soccerzdashboard.htmlc                 C   s¼   t   ¡ }tjtttd |  ƒg| dkr,dgng  ttƒddddd�}t   ¡ | }|jdkrvtd	| › d
|d›d�ƒ dS |jp~d|j	p†d }td	| › d|j› d|d›d|dd… › �ƒ | S )z,Run one build step. Returns True on success.Úmainúdashboard.pyz--quietTzutf-8Úreplace)ÚcwdZcapture_outputÚtextÚencodingÚerrorsr   z  z: ok in z.1fÚsÚ z: rc=z in zs
iàüÿÿN)
ÚtimeÚ
subprocessÚrunÚPYÚstrÚROOTÚ
returncodeÚprintÚstdoutÚstderr)ZscriptÚfatalZt0ÚpZtookÚtail© r   úmain/build_dashboard.pyÚ_run   s    ÿ
ý
,r   c                  C   s–   t  d¡} td| › d�ƒ t ¡ r,t ¡ jnd}tddd� tdd	d�sLd
S t ¡ s`tdƒ d
S t ¡ j|krztdƒ d
S tdt ¡ jd›d�ƒ dS )Nz%Y-%m-%d %H:%M:%Sú[z] rebuilding dashboardr   zresolve_live_data.pyF)r   r   Té   z9  dashboard.py exited cleanly but wrote no dashboard.htmlz"  dashboard.html was not rewrittenz  wrote ú,z bytes)	r   Ústrftimer   ÚDASHÚexistsÚstatÚst_mtimer   Úst_size)ZstampZbeforer   r   r   r   +   s    
r   Ú__main__)Ú__doc__r   Úsysr   Úpathlibr   r   r    Ú
executabler   r   r   Ú__name__Úexitr   r   r   r   Ú<module>   s   