Resources are now always downloaded if version differs.
Changed so that a new resources bundle will always downloaded if the currently downloaded version differs from the one in DEPS. BUG= TEST=gclient sync with different revisions in the /resources/webrtc-resouces-revision file. Review URL: http://webrtc-codereview.appspot.com/330033 git-svn-id: http://webrtc.googlecode.com/svn/trunk@1343 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
d6b827a28e
commit
401045a0d4
@ -28,16 +28,17 @@ def main():
|
|||||||
This script will download WebRTC resource files used for testing, like audio
|
This script will download WebRTC resource files used for testing, like audio
|
||||||
and video files. It will check the current version in the DEPS file and
|
and video files. It will check the current version in the DEPS file and
|
||||||
compare it with the one downloaded (kept in a text file in the download dir).
|
compare it with the one downloaded (kept in a text file in the download dir).
|
||||||
If there's a new version of the resources available it will be downloaded.
|
If the DEPS version is different than the one downloaded, the correct version
|
||||||
|
will be downloaded.
|
||||||
"""
|
"""
|
||||||
# Constants
|
# Constants.
|
||||||
deps_key = 'webrtc_resources_revision'
|
deps_key = 'webrtc_resources_revision'
|
||||||
remote_url_base = 'http://commondatastorage.googleapis.com/webrtc-resources/'
|
remote_url_base = 'http://commondatastorage.googleapis.com/webrtc-resources/'
|
||||||
version_filename = 'webrtc-resources-version'
|
version_filename = 'webrtc-resources-version'
|
||||||
filename_prefix = 'webrtc-resources-'
|
filename_prefix = 'webrtc-resources-'
|
||||||
extension = '.tgz'
|
extension = '.tgz'
|
||||||
|
|
||||||
# Variables used by the script
|
# Variables used by the script.
|
||||||
project_root_dir = os.path.normpath(sys.path[0] + '/../../')
|
project_root_dir = os.path.normpath(sys.path[0] + '/../../')
|
||||||
deps_file = os.path.join(project_root_dir, 'DEPS')
|
deps_file = os.path.join(project_root_dir, 'DEPS')
|
||||||
downloads_dir = os.path.join(project_root_dir, 'resources')
|
downloads_dir = os.path.join(project_root_dir, 'resources')
|
||||||
@ -66,8 +67,8 @@ def main():
|
|||||||
latest_version = int(deps_vars[deps_key])
|
latest_version = int(deps_vars[deps_key])
|
||||||
print 'Version in DEPS file: %d' % latest_version
|
print 'Version in DEPS file: %d' % latest_version
|
||||||
|
|
||||||
# Download archive if forced or latest version is newer than our current.
|
# Download archive if forced or DEPS version is different than our current.
|
||||||
if latest_version > current_version or options.force:
|
if latest_version != current_version or options.force:
|
||||||
temp_dir = tempfile.mkdtemp(prefix='webrtc-resources-')
|
temp_dir = tempfile.mkdtemp(prefix='webrtc-resources-')
|
||||||
archive_name = '%s%s%s' % (filename_prefix, latest_version, extension)
|
archive_name = '%s%s%s' % (filename_prefix, latest_version, extension)
|
||||||
remote_archive_url = urljoin(remote_url_base, archive_name)
|
remote_archive_url = urljoin(remote_url_base, archive_name)
|
||||||
@ -101,22 +102,22 @@ def main():
|
|||||||
shutil.rmtree(downloads_dir)
|
shutil.rmtree(downloads_dir)
|
||||||
os.mkdir(downloads_dir)
|
os.mkdir(downloads_dir)
|
||||||
|
|
||||||
# Write the latest version to a text file in the resources dir to avoid
|
# Write the downloaded version to a text file in the resources dir to avoid
|
||||||
# re-download of the same version in the future:
|
# re-download of the same version in the future.
|
||||||
new_version_file = os.path.join(downloads_dir, version_filename)
|
new_version_file = os.path.join(downloads_dir, version_filename)
|
||||||
f = open(new_version_file, 'w')
|
f = open(new_version_file, 'w')
|
||||||
f.write('%d' % latest_version)
|
f.write('%d' % latest_version)
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
# Extract the archive
|
# Extract the archive.
|
||||||
archive = tarfile.open(temp_file, 'r:gz')
|
archive = tarfile.open(temp_file, 'r:gz')
|
||||||
archive.extractall(downloads_dir)
|
archive.extractall(downloads_dir)
|
||||||
archive.close()
|
archive.close()
|
||||||
print 'Extracted resource files into %s' % downloads_dir
|
print 'Extracted resource files into %s' % downloads_dir
|
||||||
# Clean up the temp dir
|
# Clean up the temp dir.
|
||||||
shutil.rmtree(temp_dir)
|
shutil.rmtree(temp_dir)
|
||||||
else:
|
else:
|
||||||
print 'Already have latest (or newer) version: %s' % current_version
|
print 'Already have correct version: %s' % current_version
|
||||||
|
|
||||||
|
|
||||||
def EvalDepsFile(path):
|
def EvalDepsFile(path):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user