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

Unified Diff: scripts/slave/slave_utils.py

Issue 2391353002: Revert of Updating the SwarmingIsolatedScriptTest to upload chartjson results to the (Closed)
Patch Set: Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « scripts/slave/runtest.py ('k') | scripts/slave/unittests/runtest_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: scripts/slave/slave_utils.py
diff --git a/scripts/slave/slave_utils.py b/scripts/slave/slave_utils.py
index 7aaaff4a6070b1ddd361e335b728be0d513e3935..2571bbacb290136e8a54eb1ebb3b36be221f1c6e 100644
--- a/scripts/slave/slave_utils.py
+++ b/scripts/slave/slave_utils.py
@@ -10,7 +10,6 @@
import os
import re
import shutil
-import subprocess
import sys
import tempfile
import time
@@ -22,12 +21,6 @@
# These codes used to distinguish true errors from script warnings.
ERROR_EXIT_CODE = 1
WARNING_EXIT_CODE = 88
-
-
-# Regex matching git comment lines containing svn revision info.
-GIT_SVN_ID_RE = re.compile(r'^git-svn-id: .*@([0-9]+) .*$')
-# Regex for the master branch commit position.
-GIT_CR_POS_RE = re.compile(r'^Cr-Commit-Position: refs/heads/master@{#(\d+)}$')
# Local errors.
@@ -743,172 +736,3 @@
chromium_utils.RunCommand(zip_cmd)
GSUtilCopy(local_archive, 'gs://%s/%s' % (bucket, archive))
return 'https://storage.cloud.google.com/%s/%s' % (bucket, archive)
-
-
-def GetPerfDashboardRevisions(
- build_properties, main_revision, blink_revision, point_id=None):
- """Fills in the same revisions fields that process_log_utils does."""
- return GetPerfDashboardRevisionsWithProperties(
- build_properties.get('got_webrtc_revision'),
- build_properties.get('got_v8_revision'),
- build_properties.get('version'),
- build_properties.get('git_revision'),
- main_revision, blink_revision, point_id)
-
-
-def GetPerfDashboardRevisionsWithProperties(
- got_webrtc_revision, got_v8_revision, version, git_revision, main_revision,
- blink_revision, point_id=None):
- """Fills in the same revisions fields that process_log_utils does."""
-
- versions = {}
- versions['rev'] = main_revision
- versions['webkit_rev'] = blink_revision
- versions['webrtc_rev'] = got_webrtc_revision
- versions['v8_rev'] = got_v8_revision
- versions['ver'] = version
- versions['git_revision'] = git_revision
- versions['point_id'] = point_id
- # There are a lot of "bad" revisions to check for, so clean them all up here.
- for key in versions.keys():
- if not versions[key] or versions[key] == 'undefined':
- del versions[key]
- return versions
-
-
-def GetMainRevision(build_properties, build_dir, revision=None):
- """Return revision to use as the numerical x-value in the perf dashboard.
-
- This will be used as the value of "rev" in the data passed to
- results_dashboard.SendResults.
-
- In order or priority, this function could return:
- 1. The value of the --revision flag (IF it can be parsed as an int).
- 2. The value of "got_revision_cp" in build properties.
- 3. An SVN number, git commit position, or git commit hash.
- """
- if revision and revision.isdigit():
- return revision
- commit_pos_num = _GetCommitPos(build_properties)
- if commit_pos_num is not None:
- return commit_pos_num
- # TODO(sullivan,qyearsley): Don't fall back to _GetRevision if it returns
- # a git commit, since this should be a numerical revision. Instead, abort
- # and fail.
- return GetRevision(os.path.dirname(os.path.abspath(build_dir)))
-
-
-def GetBlinkRevision(build_dir, webkit_revision=None):
- """
- TODO(eyaich): Blink's now folded into Chromium and doesn't have a separate
- revision. Use main_revision and delete GetBlinkRevision and uses.
- """
- if webkit_revision:
- webkit_revision = webkit_revision
- else:
- try:
- webkit_dir = chromium_utils.FindUpward(
- os.path.abspath(build_dir), 'third_party', 'WebKit', 'Source')
- webkit_revision = GetRevision(webkit_dir)
- except Exception:
- webkit_revision = None
- return webkit_revision
-
-
-def GetRevision(in_directory):
- """Returns the SVN revision, git commit position, or git hash.
-
- Args:
- in_directory: A directory in the repository to be checked.
-
- Returns:
- An SVN revision as a string if the given directory is in a SVN repository,
- or a git commit position number, or if that's not available, a git hash.
- If all of that fails, an empty string is returned.
- """
- import xml.dom.minidom
- if not os.path.exists(os.path.join(in_directory, '.svn')):
- if _IsGitDirectory(in_directory):
- svn_rev = _GetGitCommitPosition(in_directory)
- if svn_rev:
- return svn_rev
- return _GetGitRevision(in_directory)
- else:
- return ''
-
- # Note: Not thread safe: http://bugs.python.org/issue2320
- output = subprocess.Popen(['svn', 'info', '--xml'],
- cwd=in_directory,
- shell=(sys.platform == 'win32'),
- stdout=subprocess.PIPE).communicate()[0]
- try:
- dom = xml.dom.minidom.parseString(output)
- return dom.getElementsByTagName('entry')[0].getAttribute('revision')
- except xml.parsers.expat.ExpatError:
- return ''
- return ''
-
-
-def _GetCommitPos(build_properties):
- """Extracts the commit position from the build properties, if its there."""
- if 'got_revision_cp' not in build_properties:
- return None
- commit_pos = build_properties['got_revision_cp']
- return int(re.search(r'{#(\d+)}', commit_pos).group(1))
-
-
-def _GetGitCommitPositionFromLog(log):
- """Returns either the commit position or svn rev from a git log."""
- # Parse from the bottom up, in case the commit message embeds the message
- # from a different commit (e.g., for a revert).
- for r in [GIT_CR_POS_RE, GIT_SVN_ID_RE]:
- for line in reversed(log.splitlines()):
- m = r.match(line.strip())
- if m:
- return m.group(1)
- return None
-
-
-def _GetGitCommitPosition(dir_path):
- """Extracts the commit position or svn revision number of the HEAD commit."""
- git_exe = 'git.bat' if sys.platform.startswith('win') else 'git'
- p = subprocess.Popen(
- [git_exe, 'log', '-n', '1', '--pretty=format:%B', 'HEAD'],
- cwd=dir_path, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
- (log, _) = p.communicate()
- if p.returncode != 0:
- return None
- return _GetGitCommitPositionFromLog(log)
-
-
-def _GetGitRevision(in_directory):
- """Returns the git hash tag for the given directory.
-
- Args:
- in_directory: The directory where git is to be run.
-
- Returns:
- The git SHA1 hash string.
- """
- git_exe = 'git.bat' if sys.platform.startswith('win') else 'git'
- p = subprocess.Popen(
- [git_exe, 'rev-parse', 'HEAD'],
- cwd=in_directory, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
- (stdout, _) = p.communicate()
- return stdout.strip()
-
-
-def _IsGitDirectory(dir_path):
- """Checks whether the given directory is in a git repository.
-
- Args:
- dir_path: The directory path to be tested.
-
- Returns:
- True if given directory is in a git repository, False otherwise.
- """
- git_exe = 'git.bat' if sys.platform.startswith('win') else 'git'
- with open(os.devnull, 'w') as devnull:
- p = subprocess.Popen([git_exe, 'rev-parse', '--git-dir'],
- cwd=dir_path, stdout=devnull, stderr=devnull)
- return p.wait() == 0
« no previous file with comments | « scripts/slave/runtest.py ('k') | scripts/slave/unittests/runtest_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698