<s> import requests <EOL> import data <EOL> def choose_mirror ( url_list ) : <EOL> """<STR_LIT>""" <EOL> for url in url_list : <EOL> print '<STR_LIT>' . format ( url ) <EOL> status_code = check_connection ( url ) <EOL> if status_code != <NUM_LIT:0> and status_code != <NUM_LIT> : <EOL> print '<STR_LIT>' . format ( url ) <EOL> return url <EOL> else : <EOL> '<STR_LIT>' . format ( str ( status_code ) ) <EOL> return None <EOL> def check_connection ( url ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> resp = requests . head ( url , timeout = data . default_timeout ) <EOL> return resp . status_code <EOL> except requests . exceptions . ConnectionError : <EOL> return <NUM_LIT:0> <EOL> except requests . exceptions . Timeout : <EOL> return <NUM_LIT:0> </s>
