From 401045a0d4ffa44e80f447b139c6584e73af93e5 Mon Sep 17 00:00:00 2001 From: "kjellander@webrtc.org" Date: Thu, 5 Jan 2012 08:05:07 +0000 Subject: [PATCH] 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 --- tools/resources/update.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/tools/resources/update.py b/tools/resources/update.py index 28c9be21b..9896d2e70 100755 --- a/tools/resources/update.py +++ b/tools/resources/update.py @@ -28,16 +28,17 @@ def main(): 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 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' remote_url_base = 'http://commondatastorage.googleapis.com/webrtc-resources/' version_filename = 'webrtc-resources-version' filename_prefix = 'webrtc-resources-' extension = '.tgz' - # Variables used by the script + # Variables used by the script. project_root_dir = os.path.normpath(sys.path[0] + '/../../') deps_file = os.path.join(project_root_dir, 'DEPS') downloads_dir = os.path.join(project_root_dir, 'resources') @@ -66,8 +67,8 @@ def main(): latest_version = int(deps_vars[deps_key]) print 'Version in DEPS file: %d' % latest_version - # Download archive if forced or latest version is newer than our current. - if latest_version > current_version or options.force: + # Download archive if forced or DEPS version is different than our current. + if latest_version != current_version or options.force: temp_dir = tempfile.mkdtemp(prefix='webrtc-resources-') archive_name = '%s%s%s' % (filename_prefix, latest_version, extension) remote_archive_url = urljoin(remote_url_base, archive_name) @@ -101,22 +102,22 @@ def main(): shutil.rmtree(downloads_dir) os.mkdir(downloads_dir) - # Write the latest version to a text file in the resources dir to avoid - # re-download of the same version in the future: + # Write the downloaded version to a text file in the resources dir to avoid + # re-download of the same version in the future. new_version_file = os.path.join(downloads_dir, version_filename) f = open(new_version_file, 'w') f.write('%d' % latest_version) f.close() - # Extract the archive + # Extract the archive. archive = tarfile.open(temp_file, 'r:gz') archive.extractall(downloads_dir) archive.close() print 'Extracted resource files into %s' % downloads_dir - # Clean up the temp dir + # Clean up the temp dir. shutil.rmtree(temp_dir) else: - print 'Already have latest (or newer) version: %s' % current_version + print 'Already have correct version: %s' % current_version def EvalDepsFile(path):