<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[281958] trunk/Tools</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/281958">281958</a></dd>
<dt>Author</dt> <dd>clopez@igalia.com</dd>
<dt>Date</dt> <dd>2021-09-02 15:09:41 -0700 (Thu, 02 Sep 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>[run-perf-tests] Add support for python3 and use it by default
https://bugs.webkit.org/show_bug.cgi?id=229783

Reviewed by Jonathan Bedard.

Make the script compatible with python3 and set it to use python3
by default. The script is still compatible with python2.

* CISupport/build-webkit-org/steps.py:
(RunAndUploadPerfTests):
* Scripts/run-perf-tests:
* Scripts/webkitpy/common/net/file_uploader.py:
(FileUploader._upload_data.callback):
(FileUploader):
* Scripts/webkitpy/performance_tests/perftestsrunner.py:
* Scripts/webkitpy/performance_tests/perftestsrunner_unittest.py:
(MainTest.test_upload_json):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkToolsCISupportbuildwebkitorgstepspy">trunk/Tools/CISupport/build-webkit-org/steps.py</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsScriptsrunperftests">trunk/Tools/Scripts/run-perf-tests</a></li>
<li><a href="#trunkToolsScriptswebkitpycommonnetfile_uploaderpy">trunk/Tools/Scripts/webkitpy/common/net/file_uploader.py</a></li>
<li><a href="#trunkToolsScriptswebkitpyperformance_testsperftestsrunnerpy">trunk/Tools/Scripts/webkitpy/performance_tests/perftestsrunner.py</a></li>
<li><a href="#trunkToolsScriptswebkitpyperformance_testsperftestsrunner_unittestpy">trunk/Tools/Scripts/webkitpy/performance_tests/perftestsrunner_unittest.py</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkToolsCISupportbuildwebkitorgstepspy"></a>
<div class="modfile"><h4>Modified: trunk/Tools/CISupport/build-webkit-org/steps.py (281957 => 281958)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/CISupport/build-webkit-org/steps.py  2021-09-02 22:00:58 UTC (rev 281957)
+++ trunk/Tools/CISupport/build-webkit-org/steps.py     2021-09-02 22:09:41 UTC (rev 281958)
</span><span class="lines">@@ -1024,7 +1024,7 @@
</span><span class="cx">     name = "perf-test"
</span><span class="cx">     description = ["perf-tests running"]
</span><span class="cx">     descriptionDone = ["perf-tests"]
</span><del>-    command = ["python", "./Tools/Scripts/run-perf-tests",
</del><ins>+    command = ["python3", "./Tools/Scripts/run-perf-tests",
</ins><span class="cx">                "--output-json-path", "perf-test-results.json",
</span><span class="cx">                "--worker-config-json-path", "../../perf-test-config.json",
</span><span class="cx">                "--no-show-results",
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (281957 => 281958)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog    2021-09-02 22:00:58 UTC (rev 281957)
+++ trunk/Tools/ChangeLog       2021-09-02 22:09:41 UTC (rev 281958)
</span><span class="lines">@@ -1,3 +1,23 @@
</span><ins>+2021-09-02  Carlos Alberto Lopez Perez  <clopez@igalia.com>
+
+        [run-perf-tests] Add support for python3 and use it by default
+        https://bugs.webkit.org/show_bug.cgi?id=229783
+
+        Reviewed by Jonathan Bedard.
+
+        Make the script compatible with python3 and set it to use python3
+        by default. The script is still compatible with python2.
+
+        * CISupport/build-webkit-org/steps.py:
+        (RunAndUploadPerfTests):
+        * Scripts/run-perf-tests:
+        * Scripts/webkitpy/common/net/file_uploader.py:
+        (FileUploader._upload_data.callback):
+        (FileUploader):
+        * Scripts/webkitpy/performance_tests/perftestsrunner.py:
+        * Scripts/webkitpy/performance_tests/perftestsrunner_unittest.py:
+        (MainTest.test_upload_json):
+
</ins><span class="cx"> 2021-09-02  Jonathan Bedard  <jbedard@apple.com>
</span><span class="cx"> 
</span><span class="cx">         [contributors.json] Relocation (Part 6)
</span></span></pre></div>
<a id="trunkToolsScriptsrunperftests"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/run-perf-tests (281957 => 281958)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/run-perf-tests       2021-09-02 22:00:58 UTC (rev 281957)
+++ trunk/Tools/Scripts/run-perf-tests  2021-09-02 22:09:41 UTC (rev 281958)
</span><span class="lines">@@ -1,4 +1,4 @@
</span><del>-#!/usr/bin/env python
</del><ins>+#!/usr/bin/env python3
</ins><span class="cx"> # Copyright (C) 2012 Google Inc. All rights reserved.
</span><span class="cx"> #
</span><span class="cx"> # Redistribution and use in source and binary forms, with or without
</span></span></pre></div>
<a id="trunkToolsScriptswebkitpycommonnetfile_uploaderpy"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/webkitpy/common/net/file_uploader.py (281957 => 281958)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/webkitpy/common/net/file_uploader.py 2021-09-02 22:00:58 UTC (rev 281957)
+++ trunk/Tools/Scripts/webkitpy/common/net/file_uploader.py    2021-09-02 22:09:41 UTC (rev 281958)
</span><span class="lines">@@ -31,6 +31,7 @@
</span><span class="cx"> import sys
</span><span class="cx"> 
</span><span class="cx"> from webkitpy.common.net.networktransaction import NetworkTransaction, NetworkTimeout
</span><ins>+from webkitcorepy import string_utils, unicode
</ins><span class="cx"> 
</span><span class="cx"> if sys.version_info > (3, 0):
</span><span class="cx">     from urllib.request import Request, urlopen
</span><span class="lines">@@ -105,7 +106,7 @@
</span><span class="cx">             # FIXME: Setting a timeout, either globally using socket.setdefaulttimeout()
</span><span class="cx">             # or in urlopen(), doesn't appear to work on Mac 10.5 with Python 2.7.
</span><span class="cx">             # For now we will ignore the timeout value and hope for the best.
</span><del>-            request = Request(self._url, data, {"Content-Type": content_type})
</del><ins>+            request = Request(self._url, string_utils.encode(data), {string_utils.encode(b'Content-Type'): string_utils.encode(content_type)})
</ins><span class="cx">             return urlopen(request)
</span><span class="cx"> 
</span><span class="cx">         return NetworkTransaction(timeout_seconds=self._timeout_seconds).run(callback)
</span></span></pre></div>
<a id="trunkToolsScriptswebkitpyperformance_testsperftestsrunnerpy"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/webkitpy/performance_tests/perftestsrunner.py (281957 => 281958)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/webkitpy/performance_tests/perftestsrunner.py        2021-09-02 22:00:58 UTC (rev 281957)
+++ trunk/Tools/Scripts/webkitpy/performance_tests/perftestsrunner.py   2021-09-02 22:09:41 UTC (rev 281958)
</span><span class="lines">@@ -32,6 +32,7 @@
</span><span class="cx"> import json
</span><span class="cx"> import logging
</span><span class="cx"> import optparse
</span><ins>+import sys
</ins><span class="cx"> import time
</span><span class="cx"> import datetime
</span><span class="cx"> 
</span><span class="lines">@@ -42,6 +43,7 @@
</span><span class="cx"> from webkitpy.common.net.file_uploader import FileUploader
</span><span class="cx"> from webkitpy.performance_tests.perftest import PerfTestFactory
</span><span class="cx"> from webkitpy.performance_tests.perftest import DEFAULT_TEST_RUNNER_COUNT
</span><ins>+from webkitcorepy import string_utils
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> _log = logging.getLogger(__name__)
</span><span class="lines">@@ -285,7 +287,7 @@
</span><span class="cx">             'buildNumber': int(build_number) if build_number else None}
</span><span class="cx"> 
</span><span class="cx">         contents = {'tests': {}}
</span><del>-        for key, value in meta_info.items():
</del><ins>+        for key, value in list(meta_info.items()):
</ins><span class="cx">             if value:
</span><span class="cx">                 contents[key] = value
</span><span class="cx"> 
</span><span class="lines">@@ -354,7 +356,7 @@
</span><span class="cx">             _log.error("Failed to upload JSON file to %s in 120s: %s" % (url, error))
</span><span class="cx">             return False
</span><span class="cx"> 
</span><del>-        response_body = [line.strip('\n') for line in response]
</del><ins>+        response_body = [string_utils.decode(line, target_type=str).strip('\n') for line in response]
</ins><span class="cx">         if response_body != ['OK']:
</span><span class="cx">             try:
</span><span class="cx">                 parsed_response = json.loads('\n'.join(response_body))
</span></span></pre></div>
<a id="trunkToolsScriptswebkitpyperformance_testsperftestsrunner_unittestpy"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/webkitpy/performance_tests/perftestsrunner_unittest.py (281957 => 281958)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/webkitpy/performance_tests/perftestsrunner_unittest.py       2021-09-02 22:00:58 UTC (rev 281957)
+++ trunk/Tools/Scripts/webkitpy/performance_tests/perftestsrunner_unittest.py  2021-09-02 22:09:41 UTC (rev 281958)
</span><span class="lines">@@ -33,7 +33,7 @@
</span><span class="cx"> import logging
</span><span class="cx"> import unittest
</span><span class="cx"> 
</span><del>-from webkitcorepy import StringIO
</del><ins>+from webkitcorepy import BytesIO
</ins><span class="cx"> 
</span><span class="cx"> from webkitpy.common.host_mock import MockHost
</span><span class="cx"> from webkitpy.port.test import TestPort
</span><span class="lines">@@ -203,16 +203,16 @@
</span><span class="cx">                     raise Exception
</span><span class="cx">                 return mock.upload_single_text_file_return_value
</span><span class="cx"> 
</span><del>-        MockFileUploader.upload_single_text_file_return_value = StringIO('OK')
</del><ins>+        MockFileUploader.upload_single_text_file_return_value = BytesIO(b'OK')
</ins><span class="cx">         self.assertTrue(runner._upload_json('https://some.host', 'some.json', '/some/path', MockFileUploader))
</span><span class="cx">         self.assertEqual(MockFileUploader.called, ['FileUploader', 'upload_single_text_file'])
</span><span class="cx"> 
</span><span class="cx">         MockFileUploader.reset()
</span><del>-        MockFileUploader.upload_single_text_file_return_value = StringIO('OK')
</del><ins>+        MockFileUploader.upload_single_text_file_return_value = BytesIO(b'OK')
</ins><span class="cx">         self.assertTrue(runner._upload_json('some.host', 'some.json', '/some/path', MockFileUploader))
</span><span class="cx"> 
</span><span class="cx">         MockFileUploader.reset()
</span><del>-        MockFileUploader.upload_single_text_file_return_value = StringIO('Some error')
</del><ins>+        MockFileUploader.upload_single_text_file_return_value = BytesIO(b'Some error')
</ins><span class="cx">         with OutputCapture(level=logging.INFO) as captured:
</span><span class="cx">             self.assertFalse(runner._upload_json('https://some.host', 'some.json', '/some/path', MockFileUploader))
</span><span class="cx">         self.assertEqual(
</span><span class="lines">@@ -227,12 +227,12 @@
</span><span class="cx">         self.assertEqual(MockFileUploader.called, ['FileUploader', 'upload_single_text_file'])
</span><span class="cx"> 
</span><span class="cx">         MockFileUploader.reset()
</span><del>-        MockFileUploader.upload_single_text_file_return_value = StringIO('{"status": "OK"}')
</del><ins>+        MockFileUploader.upload_single_text_file_return_value = BytesIO(b'{"status": "OK"}')
</ins><span class="cx">         self.assertTrue(runner._upload_json('https://some.host', 'some.json', '/some/path', MockFileUploader))
</span><span class="cx">         self.assertEqual(MockFileUploader.called, ['FileUploader', 'upload_single_text_file'])
</span><span class="cx"> 
</span><span class="cx">         MockFileUploader.reset()
</span><del>-        MockFileUploader.upload_single_text_file_return_value = StringIO('{"status": "SomethingHasFailed", "failureStored": false}')
</del><ins>+        MockFileUploader.upload_single_text_file_return_value = BytesIO(b'{"status": "SomethingHasFailed", "failureStored": false}')
</ins><span class="cx">         with OutputCapture(level=logging.INFO) as captured:
</span><span class="cx">             self.assertFalse(runner._upload_json('https://some.host', 'some.json', '/some/path', MockFileUploader))
</span><span class="cx">         serialized_json = json.dumps({'status': 'SomethingHasFailed', 'failureStored': False}, indent=4)
</span></span></pre>
</div>
</div>

</body>
</html>