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

Unified Diff: tools/telemetry/telemetry/page/page_set_archive_info.py

Issue 24294003: [Telemetry] Move WPR archives and credentials from src-internal to Cloud Storage. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Unit test fixes and .gitignore Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: tools/telemetry/telemetry/page/page_set_archive_info.py
diff --git a/tools/telemetry/telemetry/page/page_set_archive_info.py b/tools/telemetry/telemetry/page/page_set_archive_info.py
index adb76250dd91368c0ca39b69335e0c850e74affe..b63b09fddba17a53915fcb6d4790cd12c577f516 100644
--- a/tools/telemetry/telemetry/page/page_set_archive_info.py
+++ b/tools/telemetry/telemetry/page/page_set_archive_info.py
@@ -1,6 +1,7 @@
# Copyright (c) 2013 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+
import json
import logging
import os
@@ -10,12 +11,6 @@ import shutil
from telemetry.page import cloud_storage
-def _UpdateHashFile(file_path):
- with open(file_path + '.sha1', 'wb') as f:
- f.write(cloud_storage.GetHash(file_path))
- f.flush()
-
-
class PageSetArchiveInfo(object):
def __init__(self, archive_data_file_path, page_set_file_path, data):
self._archive_data_file_path = archive_data_file_path
@@ -23,8 +18,14 @@ class PageSetArchiveInfo(object):
# Back pointer to the page set file.
self._page_set_file_path = page_set_file_path
- for archive_path in data['archives']:
- cloud_storage.GetIfChanged(cloud_storage.DEFAULT_BUCKET, archive_path)
+ # Download all .wpr files.
+ try:
+ for archive_path in data['archives']:
+ cloud_storage.GetIfChanged(cloud_storage.INTERNAL_BUCKET,
+ self._WprFileNameToPath(archive_path))
+ except cloud_storage.PermissionError, e:
+ logging.warning('Could not download WPR archives.')
+ logging.warning(e)
# Map from the relative path (as it appears in the metadata file) of the
# .wpr file to a list of urls it supports.
@@ -42,8 +43,6 @@ class PageSetArchiveInfo(object):
@classmethod
def FromFile(cls, file_path, page_set_file_path):
- cloud_storage.GetIfChanged(cloud_storage.DEFAULT_BUCKET, file_path)
-
if os.path.exists(file_path):
with open(file_path, 'r') as f:
data = json.load(f)
@@ -66,7 +65,12 @@ class PageSetArchiveInfo(object):
for url in urls:
self._SetWprFileForPage(url, target_wpr_file)
shutil.move(self.temp_target_wpr_file_path, target_wpr_file_path)
- _UpdateHashFile(target_wpr_file_path)
+
+ # Update the hash file.
+ with open(target_wpr_file_path + '.sha1', 'wb') as f:
+ f.write(cloud_storage.GetHash(target_wpr_file_path))
+ f.flush()
+
self._WriteToFile()
self._DeleteAbandonedWprFiles()
@@ -108,7 +112,6 @@ class PageSetArchiveInfo(object):
with open(self._archive_data_file_path, 'w') as f:
json.dump(metadata, f, indent=4)
f.flush()
- _UpdateHashFile(self._archive_data_file_path)
def _WprFileNameToPath(self, wpr_file):
return os.path.abspath(os.path.join(self._archive_data_file_dir, wpr_file))

Powered by Google App Engine
This is Rietveld 408576698