be more clear about JAVA6/7_HOME and don't use silly defaults; on exc downloading file state which file failed

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1470150 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2013-04-20 10:54:55 +00:00
parent f72566273c
commit 5fb07458d4
1 changed files with 25 additions and 21 deletions

View File

@ -71,11 +71,10 @@ def verifyJavaVersion(version):
# http://s.apache.org/lusolr32rc2 # http://s.apache.org/lusolr32rc2
env = os.environ env = os.environ
try: try:
JAVA7_HOME = env['JAVA7_HOME'] JAVA7_HOME = env['JAVA7_HOME']
except KeyError: except KeyError:
JAVA7_HOME = '/usr/local/jdk1.7.0_01' raise RuntimeError('please set JAVA7_HOME in the env before running smokeTestRelease')
print('JAVA7_HOME is %s' % JAVA7_HOME) print('JAVA7_HOME is %s' % JAVA7_HOME)
verifyJavaVersion('1.7') verifyJavaVersion('1.7')
@ -131,26 +130,29 @@ def download(name, urlString, tmpDir, quiet=False):
if not quiet and fileName.find('.asc') == -1: if not quiet and fileName.find('.asc') == -1:
print(' already done: %.1f MB' % (os.path.getsize(fileName)/1024./1024.)) print(' already done: %.1f MB' % (os.path.getsize(fileName)/1024./1024.))
return return
fIn = urllib.request.urlopen(urlString)
fOut = open(fileName, 'wb')
success = False
try: try:
while True: fIn = urllib.request.urlopen(urlString)
s = fIn.read(65536) fOut = open(fileName, 'wb')
if s == b'': success = False
break try:
fOut.write(s) while True:
fOut.close() s = fIn.read(65536)
fIn.close() if s == b'':
success = True break
finally: fOut.write(s)
fIn.close() fOut.close()
fOut.close() fIn.close()
if not success: success = True
os.remove(fileName) finally:
if not quiet and fileName.find('.asc') == -1: fIn.close()
print(' %.1f MB' % (os.path.getsize(fileName)/1024./1024.)) fOut.close()
if not success:
os.remove(fileName)
if not quiet and fileName.find('.asc') == -1:
print(' %.1f MB' % (os.path.getsize(fileName)/1024./1024.))
except Exception as e:
raise RuntimeError('failed to download url "%s"' % urlString) from e
def load(urlString): def load(urlString):
return urllib.request.urlopen(urlString).read().decode('utf-8') return urllib.request.urlopen(urlString).read().decode('utf-8')
@ -1276,6 +1278,8 @@ def main():
print() print()
print('Usage python -u %s BaseURL version tmpDir' % sys.argv[0]) print('Usage python -u %s BaseURL version tmpDir' % sys.argv[0])
print() print()
print(' example: python3.2 -u dev-tools/scripts/smokeTestRelease.py http://people.apache.org/~whoever/staging_area/lucene-solr-4.3.0-RC1-rev1469340 4.3.0 /path/to/a/tmp/dir')
print()
sys.exit(1) sys.exit(1)
baseURL = sys.argv[1] baseURL = sys.argv[1]