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

Unified Diff: systrace/systrace/update_systrace_trace_viewer.py

Issue 1776013005: [DO NOT COMMIT] Refactor systrace to support new clock sync design (Closed) Base URL: git@github.com:catapult-project/catapult@master
Patch Set: fix categories issue Created 4 years, 9 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
« no previous file with comments | « systrace/systrace/tracing_controller.py ('k') | tracing/tracing/extras/systrace_config.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: systrace/systrace/update_systrace_trace_viewer.py
diff --git a/systrace/systrace/update_systrace_trace_viewer.py b/systrace/systrace/update_systrace_trace_viewer.py
index 09eb0553298fbcdf337611c7e25c801a8d30d24a..46087b9ee8837a8d546a1298061061655a67fcf3 100755
--- a/systrace/systrace/update_systrace_trace_viewer.py
+++ b/systrace/systrace/update_systrace_trace_viewer.py
@@ -22,13 +22,23 @@ NO_AUTO_UPDATE_ = 'NO_AUTO_UPDATE'
def create_catapult_rev_str_(revision):
+ """Create an HTML comment string giving the Catapult revision number.
+
+ Args:
+ revision: The revision number.
+ """
return '<!--' + CATAPULT_REV_ + '=' + str(revision) + '-->'
-def get_catapult_rev_in_file_():
- assert os.path.exists(SYSTRACE_TRACE_VIEWER_HTML_FILE_)
+def get_catapult_rev_in_file_(full_path):
+ """Determine the Catapult revision number of the existing trace viewer file.
+
+ Args:
+ full_path: Full path to the existing trace viewer file.
+ """
+ assert os.path.exists(full_path)
rev = ''
- with open(SYSTRACE_TRACE_VIEWER_HTML_FILE_, 'r') as f:
+ with open(full_path, 'r') as f:
lines = f.readlines()
for line in lines[::-1]:
if CATAPULT_REV_ in line:
@@ -39,6 +49,10 @@ def get_catapult_rev_in_file_():
def get_catapult_rev_in_git_():
+ """Determine the most recent Catapult revision number in git.
+
+ The Catapult revision number is the hash of the most recent commit.
+ """
try:
return subprocess.check_output(
['git', 'rev-parse', 'HEAD'],
@@ -47,7 +61,7 @@ def get_catapult_rev_in_git_():
return ''
-def update(no_auto_update=False, no_min=False):
+def update(dest=None, no_auto_update=False, no_min=False):
"""Update the systrace trace viewer html file.
When the html file exists, do not update the file if
@@ -55,11 +69,14 @@ def update(no_auto_update=False, no_min=False):
2. or the revision is not changed.
Args:
+ dest: Directory to put the systrace_trace_viewer.html file.
no_auto_update: If true, force updating the file with revision
NO_AUTO_UPDATE_. Future updates will be skipped unless this
argument is true again.
no_min: If true, skip minification when updating the file.
"""
+ output_html_file = os.path.join(dest, SYSTRACE_TRACE_VIEWER_HTML_FILE_)
+
new_rev = None
if no_auto_update:
new_rev = NO_AUTO_UPDATE_
@@ -68,13 +85,12 @@ def update(no_auto_update=False, no_min=False):
if not new_rev:
return
- if os.path.exists(SYSTRACE_TRACE_VIEWER_HTML_FILE_):
- rev_in_file = get_catapult_rev_in_file_()
+ if os.path.exists(output_html_file):
+ rev_in_file = get_catapult_rev_in_file_(output_html_file)
if rev_in_file == NO_AUTO_UPDATE_ or rev_in_file == new_rev:
return
# Generate the vulcanized result.
- output_html_file = SYSTRACE_TRACE_VIEWER_HTML_FILE_
with codecs.open(output_html_file, encoding='utf-8', mode='w') as f:
vulcanize_trace_viewer.WriteTraceViewer(
f,
« no previous file with comments | « systrace/systrace/tracing_controller.py ('k') | tracing/tracing/extras/systrace_config.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698