B
    B:\                 @   sr   d Z ddlZddlZddlZddlZejejeZ	eje	Z
eje
ddddZdd Zed	krne  dS )
zn
Script to download and bundle the latest metadata while the mechanism
is implemented on bith repo and cloud.
    NZanaconda_navigatorZstaticZcontentzmetadata.json.bz2c        
   	   C   s   d} t }tj| dd}t \}}td|  td| td|j t|d*}x"|jdd	D ]}|r\|	| q\W W d
Q R X d}t|d"}|
 }td t||}	W d
Q R X td t|d}|	|	 W d
Q R X td d
S )z>Download latest metadata.json file, compress it and budnle it.z,https://repo.anaconda.com/pkgs/metadata.jsonT)streamzDownloading:zFile:zStatus:wbi   )Z
chunk_sizeN	   rbzCompressing filezWriting compressed filez	Finished!)METADATA_PATHrequestsgettempfileZmkstempprintZstatus_codeopenZiter_contentwritereadbz2compress)
ZurlfilepathZresponseZhandleZtemppathchunkZcompression_levelfdataZcompressed_contents r   6lib/python3.7/site-packages/scripts/update_metadata.pyupdate_bundled_metadata   s(    

r   __main__)__doc__r   osr	   r   pathdirnamerealpath__file__Z	HERE_PATHZNAVIGATOR_PATHjoinr   r   __name__r   r   r   r   <module>   s   