You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by sa...@apache.org on 2016/09/12 19:51:38 UTC

lucene-solr:master: LUCENE-7425: Port -path and -details options from the Perl version, and a couple other minor cleanups

Repository: lucene-solr
Updated Branches:
  refs/heads/master 3fe148668 -> 541a8fa13


LUCENE-7425: Port -path and -details options from the Perl version, and a couple other minor cleanups


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/541a8fa1
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/541a8fa1
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/541a8fa1

Branch: refs/heads/master
Commit: 541a8fa13d82c85dd2c0baab4dfda43f961decd4
Parents: 3fe1486
Author: Steve Rowe <sa...@apache.org>
Authored: Mon Sep 12 15:49:03 2016 -0400
Committer: Steve Rowe <sa...@apache.org>
Committed: Mon Sep 12 15:51:33 2016 -0400

----------------------------------------------------------------------
 dev-tools/scripts/poll-mirrors.py | 41 +++++++++++++++++++++-------------
 1 file changed, 25 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/541a8fa1/dev-tools/scripts/poll-mirrors.py
----------------------------------------------------------------------
diff --git a/dev-tools/scripts/poll-mirrors.py b/dev-tools/scripts/poll-mirrors.py
index 1ff7e54..13c5652 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 = False
 
 pending_mirrors = []
@@ -119,18 +127,19 @@ for match in re.finditer('<TR>(.*?)</TR>', str(html), re.MULTILINE | re.IGNORECA
 
   match = 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.path
 while 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:
     break
 
   if remaining > 0:
-    p('Sleeping for {} seconds...\n'.format(remaining))
+    p('Sleeping for {:d} seconds...\n'.format(int(remaining + 0.5)))
     time.sleep(remaining)