<s> from __future__ import absolute_import , division , print_function , unicode_literals <EOL> import sys <EOL> import requests <EOL> try : <EOL> from urllib . parse import urljoin <EOL> except ImportError : <EOL> try : <EOL> from urlparse . parse import urljoin <EOL> except ImportError : <EOL> from urlparse import urljoin <EOL> if len ( sys . argv ) != <NUM_LIT:2> : <EOL> print ( '<STR_LIT>' % sys . argv [ <NUM_LIT:0> ] , file = sys . stderr ) <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> solr_version = sys . argv [ <NUM_LIT:1> ] <EOL> tarball = '<STR_LIT>' . format ( solr_version ) <EOL> dist_path = '<STR_LIT>' . format ( solr_version , tarball ) <EOL> download_url = urljoin ( '<STR_LIT>' , dist_path ) <EOL> mirror_response = requests . get ( "<STR_LIT>" % dist_path ) <EOL> if mirror_response . ok : <EOL> mirror_data = mirror_response . json ( ) <EOL> download_url = urljoin ( mirror_data [ '<STR_LIT>' ] , mirror_data [ '<STR_LIT>' ] ) <EOL> if not download_url . endswith ( tarball ) : <EOL> download_url = urljoin ( download_url , dist_path ) <EOL> print ( download_url ) </s>
