Apache Lucene open-source search software
LUCENE-7425: Port -path and -details options from the Perl version, and a couple other minor cleanups
Steve Rowe541a8fa13d82
diff --git a/dev-tools/scripts/poll-mirrors.py b/dev-tools/scripts/poll-mirrors.pyindex 1ff7e544ff8..13c56527b72 100644--- a/dev-tools/scripts/poll-mirrors.py+++ b/dev-tools/scripts/poll-mirrors.py@@ -86,16 +86,24 @@ def check_url_list(lst):if mirror_contains_file(url):p('.')else:- p('X')+ p('\nFAIL: ' + url + '\n' if args.details else 'X')ret.append(url)return ret-parser = argparse.ArgumentParser(description='Checks that all Lucene mirrors contain a copy of a release')-parser.add_argument('-version', '-v', help='Lucene version to check', required=True)-parser.add_argument('-interval', '-i', help='seconds to wait to query again pending mirrors', type=int, default=300)+desc = 'Periodically checks that all Lucene/Solr mirrors contain either a copy of a release or a specified path'+parser = argparse.ArgumentParser(description=desc)+parser.add_argument('-version', '-v', help='Lucene/Solr version to check')+parser.add_argument('-path', '-p', help='instead of a versioned release, check for some/explicit/path')+parser.add_argument('-interval', '-i', help='seconds to wait before re-querying mirrors', type=int, default=300)+parser.add_argument('-details', '-d', help='print missing mirror URLs', action='store_true', default=False)args = parser.parse_args()+if (args.version is None and args.path is None) \+ or (args.version is not None and args.path is not None):+ p('You must specify either -version or -path but not both!\n')+ sys.exit(1)+try:conn = http.HTTPConnection('www.apache.org')conn.request('GET', '/mirrors/')@@ -105,9 +113,9 @@ except Exception as e:p('Unable to fetch the Apache mirrors list!\n')sys.exit(1)-apache_path = 'lucene/java/{}/changes/Changes.html'.format(args.version);-maven_url = 'http://repo1.maven.org/maven2/' \- 'org/apache/lucene/lucene-core/{0}/lucene-core-{0}.pom.asc'.format(args.version)+mirror_path = args.path if args.path is not None else 'lucene/java/{}/changes/Changes.html'.format(args.version)+maven_url = None if args.version is None else 'http://repo1.maven.org/maven2/' \+ 'org/apache/lucene/lucene-core/{0}/lucene-core-{0}.pom.asc'.format(args.version)maven_available = Falsepending_mirrors = []@@ -119,18 +127,19 @@ for match in re.finditer('<TR>(.*?)</TR>', str(html), re.MULTILINE | re.IGNORECAmatch = re.search('<A\s+HREF\s*=\s*"([^"]+)"\s*>', row, re.MULTILINE | re.IGNORECASE)if match:- pending_mirrors.append(match.group(1) + apache_path)+ pending_mirrors.append(match.group(1) + mirror_path)total_mirrors = len(pending_mirrors)+label = args.version if args.version is not None else args.pathwhile True:- p('\n' + str(datetime.datetime.now()))+ p('\n{:%Y-%m-%d %H:%M:%S}'.format(datetime.datetime.now()))p('\nPolling {} Apache Mirrors'.format(len(pending_mirrors)))- if not maven_available:+ if maven_url is not None and not maven_available:p(' and Maven Central')p('...\n')- if not maven_available:+ if maven_url is not None and not maven_available:maven_available = mirror_contains_file(maven_url)start = time.time()@@ -140,14 +149,14 @@ while True:available_mirrors = total_mirrors - len(pending_mirrors)- p('\n\n{} is{}downloadable from Maven Central\n'.format(args.version, maven_available and ' ' or ' not '))- p('{} is downloadable from {}/{} Apache Mirrors ({:.2f}%)\n'.format(args.version, available_mirrors,- total_mirrors,- available_mirrors * 100 / total_mirrors))+ if maven_url is not None:+ p('\n\n{} is{}downloadable from Maven Central'.format(label, ' ' if maven_available else ' not '))+ p('\n{} is downloadable from {}/{} Apache Mirrors ({:.2f}%)\n'+ .format(label, available_mirrors, total_mirrors, available_mirrors * 100 / total_mirrors))if len(pending_mirrors) == 0:breakif remaining > 0:- p('Sleeping for {} seconds...\n'.format(remaining))+ p('Sleeping for {:d} seconds...\n'.format(int(remaining + 0.5)))time.sleep(remaining)