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

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

Issue 404413002: [Telemetry] Fix profile generation on Mac bots (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address review comments Created 6 years, 5 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/telemetry/telemetry/page/profile_generator.py
diff --git a/tools/telemetry/telemetry/page/profile_generator.py b/tools/telemetry/telemetry/page/profile_generator.py
index 979ece9bd2bf72b731aaf896cd2471604a78496e..a6012bf2e2b908496ae29ff3bcdb51f2943118ac 100644
--- a/tools/telemetry/telemetry/page/profile_generator.py
+++ b/tools/telemetry/telemetry/page/profile_generator.py
@@ -8,6 +8,7 @@ import logging
import optparse
import os
import shutil
+import stat
import sys
import tempfile
@@ -36,6 +37,33 @@ def _DiscoverProfileCreatorClasses():
return profile_creators
+def _IsPseudoFile(directory, paths):
+ """Filter function for shutil.copytree() to reject socket files and symlinks
+ since those can't be copied around on bots."""
+ def IsSocket(full_path):
+ """Check if a file at a given path is a socket."""
+ try:
+ if stat.S_ISSOCK(os.stat(full_path).st_mode):
+ return True
+ except OSError:
+ # Thrown if we encounter a broken symlink.
+ pass
+ return False
+
+ ignore_list = []
+ for path in paths:
+ full_path = os.path.join(directory, path)
+
+ if os.path.isdir(full_path):
+ continue
+ if not IsSocket(full_path) and not os.path.islink(full_path):
+ continue
+
+ logging.warning('Ignoring pseudo file: %s' % full_path)
+ ignore_list.append(path)
+
+ return ignore_list
+
def GenerateProfiles(profile_creator_class, profile_creator_name, options):
"""Generate a profile"""
expectations = test_expectations.TestExpectations()
@@ -60,19 +88,7 @@ def GenerateProfiles(profile_creator_class, profile_creator_name, options):
if os.path.exists(out_path):
shutil.rmtree(out_path)
- # A profile may contain pseudo files like sockets which can't be copied
- # around by bots.
- def IsPseudoFile(directory, paths):
- ignore_list = []
- for path in paths:
- full_path = os.path.join(directory, path)
- if (not os.path.isfile(full_path) and
- not os.path.isdir(full_path) and
- not os.path.islink(full_path)):
- logging.warning('Ignoring pseudo file: %s' % full_path)
- ignore_list.append(path)
- return ignore_list
- shutil.copytree(temp_output_directory, out_path, ignore=IsPseudoFile)
+ shutil.copytree(temp_output_directory, out_path, ignore=_IsPseudoFile)
shutil.rmtree(temp_output_directory)
sys.stderr.write("SUCCESS: Generated profile copied to: '%s'.\n" % out_path)
@@ -121,8 +137,7 @@ def ProcessCommandLineArgs(parser, args):
def Main():
options = browser_options.BrowserFinderOptions()
parser = options.CreateParser(
- "%%prog <--profile-type-to-generate=...> <--browser=...>"
- " <--output-directory>")
+ "%%prog <--profile-type-to-generate=...> <--browser=...> <--output-dir>")
AddCommandLineArgs(parser)
_, _ = parser.parse_args()
ProcessCommandLineArgs(parser, options)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698