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

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

Issue 99483007: [telemetry] Ensure page sets reference the right WPR archives. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 c3ed26d28995d399e9b938abbc245095c751d4dc..8fc8d15b8a64031fed9704e1569d1f86b2e9b88f 100644
--- a/tools/telemetry/telemetry/page/page_set_archive_info.py
+++ b/tools/telemetry/telemetry/page/page_set_archive_info.py
@@ -13,16 +13,13 @@ from telemetry.page import cloud_storage
class PageSetArchiveInfo(object):
- def __init__(self, archive_data_file_path, page_set_file_path, data):
- self._archive_data_file_path = archive_data_file_path
- self._archive_data_file_dir = os.path.dirname(archive_data_file_path)
+ def __init__(self, file_path, data):
+ self._file_path = file_path
+ self._base_dir = os.path.dirname(file_path)
# Ensure directory exists.
- if not os.path.exists(self._archive_data_file_dir):
- os.makedirs(self._archive_data_file_dir)
-
- # Back pointer to the page set file.
- self._page_set_file_path = page_set_file_path
+ if not os.path.exists(self._base_dir):
+ os.makedirs(self._base_dir)
# Download all .wpr files.
for archive_path in data['archives']:
@@ -61,12 +58,12 @@ class PageSetArchiveInfo(object):
self.temp_target_wpr_file_path = None
@classmethod
- def FromFile(cls, file_path, page_set_file_path):
+ def FromFile(cls, file_path):
if os.path.exists(file_path):
with open(file_path, 'r') as f:
data = json.load(f)
- return cls(file_path, page_set_file_path, data)
- return cls(file_path, page_set_file_path, {'archives': {}})
+ return cls(file_path, data)
+ return cls(file_path, {'archives': {}})
def WprFilePathForPage(self, page):
if self.temp_target_wpr_file_path:
@@ -119,21 +116,18 @@ class PageSetArchiveInfo(object):
metadata['description'] = (
'Describes the Web Page Replay archives for a page set. Don\'t edit by '
'hand! Use record_wpr for updating.')
- # Pointer from the metadata to the page set .json file.
- metadata['page_set'] = os.path.relpath(self._page_set_file_path,
- self._archive_data_file_dir)
metadata['archives'] = self._wpr_file_to_urls.copy()
# Don't write data for abandoned archives.
abandoned_wpr_files = self._AbandonedWprFiles()
for wpr_file in abandoned_wpr_files:
del metadata['archives'][wpr_file]
- with open(self._archive_data_file_path, 'w') as f:
+ with open(self._file_path, 'w') as f:
json.dump(metadata, f, indent=4)
f.flush()
def _WprFileNameToPath(self, wpr_file):
- return os.path.abspath(os.path.join(self._archive_data_file_dir, wpr_file))
+ return os.path.abspath(os.path.join(self._base_dir, wpr_file))
def _NextWprFileName(self):
"""Creates a new file name for a wpr archive file."""
@@ -152,7 +146,7 @@ class PageSetArchiveInfo(object):
if not base:
# If we're creating a completely new info file, use the base name of the
# page set file.
- base = os.path.splitext(os.path.basename(self._page_set_file_path))[0]
+ base = os.path.splitext(os.path.basename(self._file_path))[0]
new_filename = '%s_%03d.wpr' % (base, highest_number + 1)
return new_filename, self._WprFileNameToPath(new_filename)
« no previous file with comments | « tools/telemetry/telemetry/page/page_set.py ('k') | tools/telemetry/telemetry/page/page_set_archive_info_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698