Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: tools/telemetry/catapult_base/dependency_manager/dependency_manager.py

Issue 1391403003: Add priority groups to local paths in the dependency manager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import logging 5 import logging
6 import os 6 import os
7 import stat 7 import stat
8 8
9 from catapult_base import cloud_storage 9 from catapult_base import cloud_storage
10 from catapult_base import support_binaries 10 from catapult_base import support_binaries
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 207
208 Will not download the file. 208 Will not download the file.
209 209
210 Args: 210 Args:
211 dependency_info: A DependencyInfo instance for the dependency to be 211 dependency_info: A DependencyInfo instance for the dependency to be
212 found and the platform it should run on. 212 found and the platform it should run on.
213 213
214 Returns: A path to a local file, or None if not found. 214 Returns: A path to a local file, or None if not found.
215 """ 215 """
216 if dependency_info: 216 if dependency_info:
217 paths = dependency_info.local_paths 217 local_paths = dependency_info.local_paths
218 for local_path in paths: 218 found_path = None
219 if os.path.exists(local_path): 219 for priority_group in local_paths:
220 return local_path 220 # A list of paths in local_paths implies the same priority, so return
221 # the most recently modified one.
222 found_path_mtime = 0
223 for path in priority_group:
224 if os.path.exists(path):
225 mtime = os.stat(path).st_mtime
eakuefner 2015/10/09 16:29:17 mtime = os.path.getmtime(path)
226 if mtime > found_path_mtime:
227 found_path = path
228 found_path_mtime = mtime
229 if found_path:
230 return found_path
221 return None 231 return None
222 232
223 @staticmethod 233 @staticmethod
224 def _CloudStoragePath(dependency_info): 234 def _CloudStoragePath(dependency_info):
225 """Return a path to a downloaded file for |dependency_info|. 235 """Return a path to a downloaded file for |dependency_info|.
226 236
227 May not download the file if it has already been downloaded. 237 May not download the file if it has already been downloaded.
228 238
229 Args: 239 Args:
230 dependency_info: A DependencyInfo instance for the dependency to be 240 dependency_info: A DependencyInfo instance for the dependency to be
(...skipping 27 matching lines...) Expand all
258 if not os.path.exists(download_dir): 268 if not os.path.exists(download_dir):
259 os.makedirs(download_dir) 269 os.makedirs(download_dir)
260 270
261 cloud_storage.GetIfHashChanged(cs_path, download_path, cs_bucket, cs_hash) 271 cloud_storage.GetIfHashChanged(cs_path, download_path, cs_bucket, cs_hash)
262 if not os.path.exists(download_path): 272 if not os.path.exists(download_path):
263 raise exceptions.FileNotFoundError(download_path) 273 raise exceptions.FileNotFoundError(download_path)
264 #TODO(aiolos): Add support for unzipping files. 274 #TODO(aiolos): Add support for unzipping files.
265 os.chmod(download_path, 275 os.chmod(download_path,
266 stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR | stat.S_IRGRP) 276 stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR | stat.S_IRGRP)
267 return os.path.abspath(download_path) 277 return os.path.abspath(download_path)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698