Changeset 250375 in webkit
- Timestamp:
- Sep 25, 2019 7:01:53 PM (5 years ago)
- Location:
- trunk/Tools
- Files:
-
- 1 added
- 2 deleted
- 35 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r250357 r250375 1 2019-09-25 Jonathan Bedard <jbedard@apple.com> 2 3 Python 3: Add support in webkitpy.common.system 4 https://bugs.webkit.org/show_bug.cgi?id=201826 5 <rdar://problem/55452671> 6 7 Reviewed by Stephanie Lewis. 8 9 Tested compatibility by running 'python3 -m unittest webkitpy.common.system.<_unittest>' on 10 each of the effected files. 11 12 * Scripts/webkitpy/common/checkout/changelog.py: Import StringIO from io module. 13 (set_reviewer): 14 (set_short_description_and_bug_url): 15 * Scripts/webkitpy/common/checkout/checkout.py: Import StringIO from io module. 16 (Checkout._latest_entry_for_changelog_at_revision): 17 * Scripts/webkitpy/common/config/committers.py: 18 (CommitterList.load_json): iteritems -> items. 19 * Scripts/webkitpy/common/net/networktransaction.py: 20 (NetworkTransaction.run): urllib2 is urllib in Python3. 21 * Scripts/webkitpy/common/system/abstractexecutive.py: 22 (AbstractExecutive._stringify_args): 23 (AbstractExecutive.command_for_printing): The str type is unicode in Python3. 24 * Scripts/webkitpy/common/system/crashlogs_unittest.py: Explicitly encode and decode binary crashlogs. 25 * Scripts/webkitpy/common/system/environment_unittest.py: Use absolute imports. 26 * Scripts/webkitpy/common/system/executive.py: 27 (ScriptError.message_with_output): The str type is unicode in Python3. 28 (Executive.WrappedPopen): Python3's Popen object is a context manager. To allow us to use it as one, 29 our Python2 Popen needs to be one as well. 30 (Executive.WrappedPopen.__init__): 31 (Executive.WrappedPopen.__enter__): 32 (Executive.WrappedPopen.__exit__): 33 (Executive._run_command_with_teed_output): Simplify loop, decode unicode strings. 34 (Executive.run_and_throw_if_fail): The child output file should not be unicode strings. 35 (Executive.running_pids): Use the Popen context manager to guarantee clean-up. 36 (Executive._compute_stdin): 37 (Executive.run_command): Use the Popen context manager to guarantee clean-up. 38 (Executive._stringify_args): The str type is unicode in Python3. 39 (Executive.popen): Return a context manager if the Popen object is not one. 40 * Scripts/webkitpy/common/system/executive_mock.py: 41 (MockProcess.__init__): StringIO -> BytesIO. 42 (MockProcess.__enter__): 43 (MockProcess): 44 (MockProcess.__exit__): 45 * Scripts/webkitpy/common/system/executive_unittest.py: 46 (ExecutiveTest.test_auto_stringify_args): Use the Popen context manager to guarantee clean-up. 47 (ExecutiveTest.test_popen_args): Ditto. 48 (ExecutiveTest.serial_test_kill_process): Ditto. 49 (ExecutiveTest.serial_test_kill_all): Ditto. 50 * Scripts/webkitpy/common/system/filesystem.py: 51 (FileSystem.read_binary_file): Use 'open' instead of 'file'. 52 (FileSystem.write_binary_file): Ditto. 53 (FileSystem.write_text_file): The str type is unicode in Python3. 54 (FileSystem.relpath): 55 (FileSystem.remove): The WindowsError is just anther OSError in Python3. 56 (FileSystem._WindowsError): Deleted. 57 * Scripts/webkitpy/common/system/filesystem_mock.py: 58 (MockFileSystem.glob): filter returns a generator instead of a list. 59 (WritableBinaryFileObject.__init__): Binary files are comprised of bytes, not string in Python3. 60 (WritableBinaryFileObject.write): Ditto. 61 (ReadableTextFileObject.__init__): Ditto. 62 * Scripts/webkitpy/common/system/filesystem_mock_unittest.py: 63 (MockFileSystemTest.test_normpath): 64 (MockFileSystemTest.test_dirs_under): assertEquals -> assertEqual. 65 * Scripts/webkitpy/common/system/filesystem_unittest.py: 66 (RealFileSystemTest.test_read_and_write_file): Explicitly define byte arrays instead of strings. 67 (RealFileSystemTest.test_remove_file_with_retry.remove_with_exception): The WindowsError is just 68 anther OSError in Python3. 69 * Scripts/webkitpy/common/system/outputcapture.py: 70 * Scripts/webkitpy/common/system/outputtee_unittest.py: 71 (SimpleTeeTest.test_simple_tee): 72 * Scripts/webkitpy/common/system/path.py: 73 (_escape): urllib library has been broken into parts. 74 * Scripts/webkitpy/common/system/pemfile.py: 75 (_parse_pem_format.find_end): Python3 does not define a maxint. 76 * Scripts/webkitpy/common/system/pemfile_unittest.py: 77 * Scripts/webkitpy/common/system/platforminfo.py: 78 (PlatformInfo.total_bytes_memory): Not 'long' type in Python3. 79 * Scripts/webkitpy/common/system/platforminfo_unittest.py: 80 (TestPlatformInfo.test_real_code): assertNotEquals -> assertNotEqual. 81 (TestPlatformInfo.test_display_name): Ditto. 82 * Scripts/webkitpy/common/system/profiler.py: 83 (ProfilerFactory.create_profiler): Manually implement ifilter. 84 * Scripts/webkitpy/common/system/profiler_unittest.py: Use absolute imports. 85 * Scripts/webkitpy/common/system/stack_utils_unittest.py: 86 (current_thread_id): items() returns a generator in Python3. 87 * Scripts/webkitpy/common/system/systemhost.py: Use absolute imports. 88 * Scripts/webkitpy/common/system/urlfetcher.py: Removed. 89 * Scripts/webkitpy/common/system/urlfetcher_mock.py: Removed. 90 * Scripts/webkitpy/common/system/user.py: 91 (User.prompt): Use absolute imports, raw_input -> input. 92 (User.prompt_with_multiple_lists): 93 (User.prompt_with_list): 94 (User.confirm): 95 * Scripts/webkitpy/common/unicode.py: Tooling to manage compatibility between Python 2 96 and Python 3 unicode handling. 97 * Scripts/webkitpy/common/system/user_mock.py: 98 (MockUser.prompt): raw_input -> input. 99 (MockUser.prompt_with_list): Ditto. 100 * Scripts/webkitpy/common/version.py: 101 (Version.from_iterable): xrange -> range. 102 (Version.from_name): Use absolute import path. 103 (Version.__contains__): xrange -> range. 104 (Version.__str__): xrange -> range. 105 (Version.__cmp__): amp is no longer an operator in Python3, but versions are comprised 106 Of integers, so subtraction has the same effect. 107 (Version): 108 (Version.__eq__): __cmp__ operator is no longer respected, so we need to implement 109 each comparison. 110 (Version.__ne__): Ditto. 111 (Version.__lt__): Ditto. 112 (Version.__le__): Ditto. 113 (Version.__gt__): Ditto. 114 (Version.__ge__): Ditto. 115 * Scripts/webkitpy/common/version_name_map.py: 116 (VersionNameMap._automap_to_major_version): 117 (VersionNameMap.to_name): xrange -> range. 118 (VersionNameMap.from_name): iteritems -> items. 119 * Scripts/webkitpy/common/version_name_map_unittest.py: Use absolute imports. 120 * Scripts/webkitpy/common/version_unittest.py: Ditto. 121 * Scripts/webkitpy/common/wavediff.py: 122 (WaveDiff.__init__): StringIO -> BytesIO. 123 * Scripts/webkitpy/port/__init__.py: 124 (outside): 125 1 126 2019-09-25 Aakash Jain <aakash_jain@apple.com> 2 127 -
trunk/Tools/Scripts/webkitpy/common/checkout/changelog.py
r234663 r250375 31 31 import logging 32 32 import re 33 from StringIO import StringIO34 33 import textwrap 35 34 36 35 from webkitpy.common.config.committers import CommitterList 37 36 from webkitpy.common.system.filesystem import FileSystem 37 from webkitpy.common.unicode_compatibility import StringIO 38 38 import webkitpy.common.config.urls as config_urls 39 39 -
trunk/Tools/Scripts/webkitpy/common/checkout/checkout.py
r228303 r250375 27 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 28 29 import StringIO30 31 29 from webkitpy.common.config import urls 32 30 from webkitpy.common.checkout.changelog import ChangeLog, parse_bug_id_from_changelog … … 35 33 from webkitpy.common.memoized import memoized 36 34 from webkitpy.common.system.executive import ScriptError 35 from webkitpy.common.unicode_compatibility import StringIO 37 36 38 37 … … 62 61 # expects a file-like object which vends unicode(), so we decode here. 63 62 # Old revisions of Sources/WebKit/wx/ChangeLog have some invalid utf8 characters. 64 changelog_file = StringIO .StringIO(changelog_contents.decode("utf-8", "ignore"))63 changelog_file = StringIO(changelog_contents.decode("utf-8", "ignore")) 65 64 return ChangeLog.parse_latest_entry_from_file(changelog_file) 66 65 -
trunk/Tools/Scripts/webkitpy/common/config/committers.py
r225733 r250375 202 202 self._reviewers = [] 203 203 204 for name, data in contributors.ite ritems():204 for name, data in contributors.items(): 205 205 contributor = None 206 206 status = data.get('status') -
trunk/Tools/Scripts/webkitpy/common/net/networktransaction.py
r229627 r250375 28 28 29 29 import logging 30 import sys 30 31 import time 31 import urllib2 32 33 if sys.version_info > (3, 0): 34 from urllib.error import HTTPError, URLError 35 else: 36 from urllib2 import HTTPError, URLError 32 37 33 38 _log = logging.getLogger(__name__) … … 52 57 try: 53 58 return request() 54 except urllib2.HTTPError as e:59 except HTTPError as e: 55 60 if self._convert_404_to_None and e.code == 404: 56 61 return None … … 58 63 _log.warn("Received HTTP status %s loading \"%s\". Retrying in %s seconds..." % (e.code, e.filename, self._backoff_seconds)) 59 64 self._sleep() 60 except urllib2.URLError as e:65 except URLError as e: 61 66 self._check_for_timeout() 62 67 _log.warn('Received URLError: "{}" while loading {}. Retrying in {} seconds...'.format(e.reason, url, self._backoff_seconds)) -
trunk/Tools/Scripts/webkitpy/common/system/abstractexecutive.py
r243373 r250375 25 25 26 26 from webkitpy.common.system.filesystem import FileSystem 27 27 from webkitpy.common import unicode_compatibility 28 28 29 29 class AbstractExecutive(object): … … 102 102 103 103 def _stringify_args(self, args): 104 return map(unicode , args)104 return map(unicode_compatibility.unicode, args) 105 105 106 106 def command_for_printing(self, args): … … 108 108 The string should be copy/paste ready for execution in a shell.""" 109 109 args = self._stringify_args(args) 110 escaped_args = [] 111 for arg in args: 112 if isinstance(arg, unicode): 113 # Escape any non-ascii characters for easy copy/paste 114 arg = arg.encode("unicode_escape") 115 # FIXME: Do we need to fix quotes here? 116 escaped_args.append(arg) 117 return " ".join(escaped_args) 110 return unicode_compatibility.decode_if_necessary(unicode_compatibility.encode_if_necessary(' '.join(args), 'unicode_escape')) 118 111 119 112 def run_command(self, args, cwd=None, env=None, input=None, error_handler=None, ignore_errors=False, -
trunk/Tools/Scripts/webkitpy/common/system/crashlogs.py
r245544 r250375 31 31 import logging 32 32 import re 33 34 from webkitpy.common import unicode_compatibility 33 35 34 36 … … 110 112 try: 111 113 if not newer_than or self._host.filesystem.mtime(path) > newer_than: 112 log_file = self._host.filesystem.read_binary_file(path).decode('ascii', 'ignore')114 log_file = unicode_compatibility.decode_if_necessary(self._host.filesystem.read_binary_file(path), 'ascii', 'ignore') 113 115 match = self.GLOBAL_PID_REGEX.search(log_file) 114 116 if match: -
trunk/Tools/Scripts/webkitpy/common/system/crashlogs_unittest.py
r220708 r250375 28 28 from webkitpy.common.system.systemhost import SystemHost 29 29 from webkitpy.common.system.systemhost_mock import MockSystemHost 30 from webkitpy. thirdparty.mock import Mock30 from webkitpy.common import unicode_compatibility 31 31 32 32 # Needed to support Windows port tests … … 299 299 self.files['/Users/mock/Library/Logs/DiagnosticReports/DumpRenderTree_2011-06-13-150722_quadzen.crash'] = self.other_process_mock_crash_report 300 300 self.files['/Users/mock/Library/Logs/DiagnosticReports/DumpRenderTree_2011-06-13-150723_quadzen.crash'] = self.misformatted_mock_crash_report 301 302 self.files = {key: unicode_compatibility.encode_if_necessary(value) for key, value in self.files.items()} 303 301 304 self.filesystem = MockFileSystem(self.files) 302 305 crash_logs = CrashLogs(MockSystemHost(filesystem=self.filesystem), CrashLogsTest.DARWIN_MOCK_CRASH_DIRECTORY) … … 314 317 self.assertEqual(len(all_logs), 8) 315 318 316 for test, crash_log in all_logs.ite ritems():317 self.assertTrue(crash_log in self.files.values())319 for test, crash_log in all_logs.items(): 320 self.assertTrue(crash_log in [unicode_compatibility.decode_if_necessary(value) for value in self.files.values()]) 318 321 if test.split('-')[0] != 'Sandbox': 319 322 self.assertTrue(test == "Unknown" or int(test.split("-")[1]) in range(28527, 28531)) -
trunk/Tools/Scripts/webkitpy/common/system/environment_unittest.py
r221926 r250375 29 29 import unittest 30 30 31 from .environment import Environment31 from webkitpy.common.system.environment import Environment 32 32 33 33 -
trunk/Tools/Scripts/webkitpy/common/system/executive.py
r243373 r250375 28 28 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 29 30 import StringIO31 30 import errno 32 31 import logging … … 40 39 from webkitpy.common.system.abstractexecutive import AbstractExecutive 41 40 from webkitpy.common.system.outputtee import Tee 41 from webkitpy.common import unicode_compatibility 42 42 43 43 … … 72 72 (self, output_limit, self.output[-output_limit:]) 73 73 return u"%s\n\n%s" % (self, self.output) 74 return unicode (self)74 return unicode_compatibility.unicode(self) 75 75 76 76 def command_name(self): … … 84 84 PIPE = subprocess.PIPE 85 85 STDOUT = subprocess.STDOUT 86 87 class WrappedPopen(object): 88 def __init__(self, popen): 89 for attribute in dir(popen): 90 if attribute.startswith('__'): 91 continue 92 setattr(self, attribute, getattr(popen, attribute)) 93 94 def __enter__(self): 95 return self 96 97 def __exit__(self, *args): 98 self.wait() 86 99 87 100 def __init__(self): … … 109 122 **kwargs) 110 123 111 # Use our own custom wait loop because Popen ignores a tee'd 112 # stderr/stdout. 113 # FIXME: This could be improved not to flatten output to stdout. 114 while True: 115 output_line = child_process.stdout.readline() 116 if output_line == "" and child_process.poll() != None: 117 # poll() is not threadsafe and can throw OSError due to: 118 # http://bugs.python.org/issue1731717 119 return child_process.poll() 120 # We assume that the child process wrote to us in utf-8, 121 # so no re-encoding is necessary before writing here. 122 teed_output.write(output_line) 124 with child_process: 125 # Use our own custom wait loop because Popen ignores a tee'd 126 # stderr/stdout. 127 # FIXME: This could be improved not to flatten output to stdout. 128 while child_process.poll() is None: 129 output_line = child_process.stdout.readline() 130 teed_output.write(unicode_compatibility.decode_for(output_line, str)) 123 131 124 132 # FIXME: Remove this deprecated method and move callers to run_command. … … 129 137 def run_and_throw_if_fail(self, args, quiet=False, decode_output=True, **kwargs): 130 138 # Cache the child's output locally so it can be used for error reports. 131 child_out_file = StringIO.StringIO()139 child_out_file = unicode_compatibility.StringIO() 132 140 tee_stdout = sys.stdout 133 if quiet: 134 dev_null = open(os.devnull, "w") # FIXME: Does this need an encoding? 135 tee_stdout = dev_null 136 child_stdout = Tee(child_out_file, tee_stdout) 137 exit_code = self._run_command_with_teed_output(args, child_stdout, **kwargs) 138 if quiet: 139 dev_null.close() 141 try: 142 if quiet: 143 dev_null = open(os.devnull, "w") # FIXME: Does this need an encoding? 144 tee_stdout = dev_null 145 child_stdout = Tee(child_out_file, tee_stdout) 146 exit_code = self._run_command_with_teed_output(args, child_stdout, **kwargs) 147 finally: 148 if quiet: 149 dev_null.close() 140 150 141 151 child_output = child_out_file.getvalue() … … 143 153 144 154 if decode_output: 145 child_output = child_output.decode(self._child_process_encoding()) 155 child_output = unicode_compatibility.decode_if_necessary(child_output, self._child_process_encoding()) 156 else: 157 child_output = unicode_compatibility.encode_if_necessary(child_output, self._child_process_encoding()) 146 158 147 159 if exit_code: … … 287 299 pass 288 300 else: 289 ps_process = self.popen(['ps', '-eo', 'pid,comm'], stdout=self.PIPE, stderr=self.PIPE)290 stdout, _ = ps_process.communicate()291 for line in stdout.splitlines():292 try:293 # In some cases the line can contain one or more294 # leading white-spaces, so strip it before split.295 pid, process_name = line.strip().split(' ', 1)296 if process_name_filter(process_name):297 running_pids.append(int(pid))298 except ValueError as e:299 pass301 with self.popen(['ps', '-eo', 'pid,comm'], stdout=self.PIPE, stderr=self.PIPE) as ps_process: 302 stdout, _ = ps_process.communicate() 303 for line in stdout.splitlines(): 304 try: 305 # In some cases the line can contain one or more 306 # leading white-spaces, so strip it before split. 307 pid, process_name = line.strip().split(' ', 1) 308 if process_name_filter(process_name): 309 running_pids.append(int(pid)) 310 except ValueError as e: 311 pass 300 312 301 313 return sorted(running_pids) … … 356 368 # for an example of a regresion caused by passing a unicode string directly. 357 369 # FIXME: We may need to encode differently on different platforms. 358 if isinstance(input, unicode): 359 input = input.encode(self._child_process_encoding()) 370 input = unicode_compatibility.encode_if_necessary(input, self._child_process_encoding()) 360 371 return (self.PIPE, input) 361 372 … … 385 396 env=env, 386 397 close_fds=self._should_close_fds()) 387 output = process.communicate(string_to_communicate)[0] 388 389 # run_command automatically decodes to unicode() and converts CRLF to LF unless explicitly told not to. 390 if decode_output: 391 output = output.decode(self._child_process_encoding()).replace('\r\n', '\n') 392 393 # wait() is not threadsafe and can throw OSError due to: 394 # http://bugs.python.org/issue1731717 395 exit_code = process.wait() 396 397 _log.debug('"%s" took %.2fs' % (self.command_for_printing(args), time.time() - start_time)) 398 399 if return_exit_code: 400 return exit_code 401 402 if exit_code: 403 script_error = ScriptError(script_args=args, 404 exit_code=exit_code, 405 output=output, 406 cwd=cwd) 407 408 if ignore_errors: 409 assert error_handler is None, "don't specify error_handler if ignore_errors is True" 410 error_handler = Executive.ignore_error 411 412 (error_handler or self.default_error_handler)(script_error) 413 return output 398 with process: 399 if not string_to_communicate: 400 output = process.communicate()[0] 401 else: 402 output = process.communicate(unicode_compatibility.encode_if_necessary(string_to_communicate, 'utf-8'))[0] 403 404 # run_command automatically decodes to unicode() and converts CRLF to LF unless explicitly told not to. 405 if decode_output: 406 output = unicode_compatibility.decode_if_necessary(output, self._child_process_encoding()).replace('\r\n', '\n') 407 408 # wait() is not threadsafe and can throw OSError due to: 409 # http://bugs.python.org/issue1731717 410 exit_code = process.wait() 411 412 _log.debug('"%s" took %.2fs' % (self.command_for_printing(args), time.time() - start_time)) 413 414 if return_exit_code: 415 return exit_code 416 417 if exit_code: 418 script_error = ScriptError(script_args=args, 419 exit_code=exit_code, 420 output=output, 421 cwd=cwd) 422 423 if ignore_errors: 424 assert error_handler is None, "don't specify error_handler if ignore_errors is True" 425 error_handler = Executive.ignore_error 426 427 (error_handler or self.default_error_handler)(script_error) 428 return output 414 429 415 430 def _child_process_encoding(self): … … 442 457 if not self._should_encode_child_process_arguments(): 443 458 return argument 444 return argument.encode(self._child_process_encoding())459 return unicode_compatibility.encode_if_necessary(argument, self._child_process_encoding()) 445 460 446 461 def _stringify_args(self, args): 447 462 # Popen will throw an exception if args are non-strings (like int()) 448 string_args = map(unicode , args)463 string_args = map(unicode_compatibility.unicode, args) 449 464 # The Windows implementation of Popen cannot handle unicode strings. :( 450 465 return map(self._encode_argument_if_needed, string_args) … … 479 494 else: 480 495 string_args = self._stringify_args(args) 481 return subprocess.Popen(string_args, **kwargs) 496 497 # Python 3 treats Popen as a context manager, we should allow this in Python 2 498 result = subprocess.Popen(string_args, **kwargs) 499 if not callable(getattr(result, "__enter__", None)) and not callable(getattr(result, "__exit__", None)): 500 return self.WrappedPopen(result) 501 return result 482 502 483 503 def run_in_parallel(self, command_lines_and_cwds, processes=None): -
trunk/Tools/Scripts/webkitpy/common/system/executive_mock.py
r243373 r250375 27 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 28 29 import StringIO30 29 import logging 31 30 import os 32 31 32 from webkitpy.common.unicode_compatibility import BytesIO, unicode 33 33 from webkitpy.common.system.executive import ScriptError 34 34 … … 39 39 def __init__(self, stdout='MOCK STDOUT\n', stderr=''): 40 40 self.pid = 42 41 self.stdout = StringIO.StringIO(stdout)42 self.stderr = StringIO.StringIO(stderr)43 self.stdin = StringIO.StringIO()41 self.stdout = BytesIO(stdout) 42 self.stderr = BytesIO(stderr) 43 self.stdin = BytesIO() 44 44 self.returncode = 0 45 45 self._is_running = False … … 57 57 return None 58 58 return self.returncode 59 60 def __enter__(self): 61 return self 62 63 def __exit__(self, *args): 64 self.wait() 59 65 60 66 -
trunk/Tools/Scripts/webkitpy/common/system/executive_unittest.py
r243373 r250375 47 47 from webkitpy.common.system.executive import Executive, ScriptError 48 48 from webkitpy.common.system.filesystem_mock import MockFileSystem 49 from webkitpy.common import unicode_compatibility 49 50 50 51 … … 119 120 executive = Executive() 120 121 executive.run_command(command_line('echo', 1)) 121 executive.popen(command_line('echo', 1), stdout=executive.PIPE).wait() 122 self.assertEqual('echo 1', executive.command_for_printing(['echo', 1])) 122 with executive.popen(command_line('echo', 1), stdout=executive.PIPE) as process: 123 process.wait() 124 self.assertEqual('echo 1', executive.command_for_printing(['echo', 1])) 123 125 124 126 def test_popen_args(self): 125 127 executive = Executive() 126 128 # Explicitly naming the 'args' argument should not thow an exception. 127 executive.popen(args=command_line('echo', 1), stdout=executive.PIPE).wait() 129 with executive.popen(args=command_line('echo', 1), stdout=executive.PIPE) as process: 130 process.wait() 128 131 129 132 def test_run_command_with_unicode(self): … … 136 139 else: 137 140 encoding = 'utf-8' 138 encoded_tor = unicode_ tor_input.encode(encoding)141 encoded_tor = unicode_compatibility.encode_if_necessary(unicode_tor_input, encoding) 139 142 # On Windows, we expect the unicode->mbcs->unicode roundtrip to be 140 143 # lossy. On other platforms, we expect a lossless roundtrip. 141 144 if sys.platform.startswith('win'): 142 unicode_tor_output = encoded_tor.decode(encoding)145 unicode_tor_output = unicode_compatibility.decode_if_necessary(encoded_tor, encoding) 143 146 else: 144 147 unicode_tor_output = unicode_tor_input … … 168 171 def serial_test_kill_process(self): 169 172 executive = Executive() 170 process = subprocess.Popen(never_ending_command(), stdout=subprocess.PIPE)171 self.assertEqual(process.poll(), None) # Process is running172 executive.kill_process(process.pid)173 # Note: Can't use a ternary since signal.SIGKILL is undefined for sys.platform == "win32"174 if sys.platform.startswith('win'):175 # FIXME: https://bugs.webkit.org/show_bug.cgi?id=54790176 # We seem to get either 0 or 1 here for some reason.177 self.assertIn(process.wait(), (0, 1))178 elif sys.platform == "cygwin":179 # FIXME: https://bugs.webkit.org/show_bug.cgi?id=98196180 # cygwin seems to give us either SIGABRT or SIGKILL181 # Native Windows (via Cygwin) returns ENOTBLK (-15)182 self.assertIn(process.wait(), (-signal.SIGABRT, -signal.SIGKILL, -15))183 else:184 expected_exit_code = -signal.SIGTERM185 self.assertEqual(process.wait(), expected_exit_code)186 187 # Killing again should fail silently.188 executive.kill_process(process.pid)173 with executive.popen(never_ending_command(), stdout=subprocess.PIPE) as process: 174 self.assertEqual(process.poll(), None) # Process is running 175 executive.kill_process(process.pid) 176 # Note: Can't use a ternary since signal.SIGKILL is undefined for sys.platform == "win32" 177 if sys.platform.startswith('win'): 178 # FIXME: https://bugs.webkit.org/show_bug.cgi?id=54790 179 # We seem to get either 0 or 1 here for some reason. 180 self.assertIn(process.wait(), (0, 1)) 181 elif sys.platform == "cygwin": 182 # FIXME: https://bugs.webkit.org/show_bug.cgi?id=98196 183 # cygwin seems to give us either SIGABRT or SIGKILL 184 # Native Windows (via Cygwin) returns ENOTBLK (-15) 185 self.assertIn(process.wait(), (-signal.SIGABRT, -signal.SIGKILL, -15)) 186 else: 187 expected_exit_code = -signal.SIGTERM 188 self.assertEqual(process.wait(), expected_exit_code) 189 190 # Killing again should fail silently. 191 executive.kill_process(process.pid) 189 192 190 193 def serial_test_kill_all(self): 191 194 executive = Executive() 192 process = subprocess.Popen(never_ending_command(), stdout=subprocess.PIPE)193 self.assertIsNone(process.poll()) # Process is running194 executive.kill_all(never_ending_command()[0])195 # Note: Can't use a ternary since signal.SIGTERM is undefined for sys.platform == "win32"196 if sys.platform == "cygwin":197 expected_exit_code = 0 # os.kill results in exit(0) for this process.198 self.assertEqual(process.wait(), expected_exit_code)199 elif sys.platform.startswith('win'):200 # FIXME: https://bugs.webkit.org/show_bug.cgi?id=54790201 # We seem to get either 0 or 1 here for some reason.202 self.assertIn(process.wait(), (0, 1))203 else:204 expected_exit_code = -signal.SIGTERM205 self.assertEqual(process.wait(), expected_exit_code)206 # Killing again should fail silently.207 executive.kill_all(never_ending_command()[0])195 with executive.popen(never_ending_command(), stdout=subprocess.PIPE) as process: 196 self.assertIsNone(process.poll()) # Process is running 197 executive.kill_all(never_ending_command()[0]) 198 # Note: Can't use a ternary since signal.SIGTERM is undefined for sys.platform == "win32" 199 if sys.platform == "cygwin": 200 expected_exit_code = 0 # os.kill results in exit(0) for this process. 201 self.assertEqual(process.wait(), expected_exit_code) 202 elif sys.platform.startswith('win'): 203 # FIXME: https://bugs.webkit.org/show_bug.cgi?id=54790 204 # We seem to get either 0 or 1 here for some reason. 205 self.assertIn(process.wait(), (0, 1)) 206 else: 207 expected_exit_code = -signal.SIGTERM 208 self.assertEqual(process.wait(), expected_exit_code) 209 # Killing again should fail silently. 210 executive.kill_all(never_ending_command()[0]) 208 211 209 212 def _assert_windows_image_name(self, name, expected_windows_name): -
trunk/Tools/Scripts/webkitpy/common/system/filesystem.py
r229781 r250375 31 31 import codecs 32 32 import errno 33 import exceptions34 33 import filecmp 35 34 import glob … … 40 39 import tempfile 41 40 import time 41 42 from webkitpy.common.unicode_compatibility import decode_if_necessary 42 43 43 44 … … 222 223 def read_binary_file(self, path): 223 224 """Return the contents of the file at the given path as a byte string.""" 224 with file(path, 'rb') as f:225 with open(path, 'rb') as f: 225 226 return f.read() 226 227 227 228 def write_binary_file(self, path, contents): 228 with file(path, 'wb') as f:229 with open(path, 'wb') as f: 229 230 f.write(contents) 230 231 … … 257 258 The file is written encoded as UTF-8 with no BOM.""" 258 259 with codecs.open(path, 'w', 'utf-8', errors=errors) as f: 259 f.write( contents.decode('utf-8', errors=errors) if type(contents) == str else contents)260 f.write(decode_if_necessary(contents, errors=errors)) 260 261 261 262 def sha1(self, path): … … 265 266 def relpath(self, path, start='.'): 266 267 return os.path.relpath(path, start) 267 268 class _WindowsError(exceptions.OSError):269 """Fake exception for Linux and Mac."""270 pass271 268 272 269 def remove(self, path, osremove=os.remove): … … 276 273 will retry for a few seconds until Windows is done with the file.""" 277 274 try: 278 exceptions.WindowsError279 except AttributeError:280 exceptions.WindowsError = FileSystem._WindowsError275 WinOSError = WindowsError 276 except NameError: 277 WinOSError = OSError 281 278 282 279 retry_timeout_sec = 3.0 … … 286 283 osremove(path) 287 284 return True 288 except exceptions.WindowsError as e:285 except WinOSError as e: 289 286 time.sleep(sleep_interval) 290 287 retry_timeout_sec -= sleep_interval -
trunk/Tools/Scripts/webkitpy/common/system/filesystem_mock.py
r220150 r250375 27 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 28 29 import StringIO30 29 import errno 31 30 import hashlib 32 31 import os 33 32 import re 34 33 import sys 34 35 from webkitpy.common import unicode_compatibility 35 36 from webkitpy.common.system import path 36 37 37 38 38 class MockFileSystem(object): … … 187 187 # We could use fnmatch.fnmatch, but that might not do the right thing on windows. 188 188 existing_files = [path for path, contents in self.files.items() if contents is not None] 189 return filter(path_filter, existing_files) + filter(path_filter, self.dirs)189 return list(filter(path_filter, existing_files)) + list(filter(path_filter, self.dirs)) 190 190 191 191 def isabs(self, path): … … 345 345 346 346 def write_text_file(self, path, contents, errors='strict'): 347 return self.write_binary_file(path, contents.encode('utf-8', errors=errors))347 return self.write_binary_file(path, unicode_compatibility.encode_if_necessary(contents, 'utf-8', errors=errors)) 348 348 349 349 def sha1(self, path): … … 442 442 self.path = path 443 443 self.closed = False 444 self.fs.files[path] = ""444 self.fs.files[path] = b'' 445 445 446 446 def __enter__(self): … … 453 453 self.closed = True 454 454 455 def write(self, str ):456 self.fs.files[self.path] += str455 def write(self, string): 456 self.fs.files[self.path] += unicode_compatibility.encode_if_necessary(string, 'utf-8') 457 457 self.fs.written_files[self.path] = self.fs.files[self.path] 458 458 … … 460 460 class WritableTextFileObject(WritableBinaryFileObject): 461 461 def write(self, str): 462 WritableBinaryFileObject.write(self, str.encode('utf-8'))462 WritableBinaryFileObject.write(self, unicode_compatibility.encode_if_necessary(str, 'utf-8')) 463 463 464 464 … … 490 490 class ReadableTextFileObject(ReadableBinaryFileObject): 491 491 def __init__(self, fs, path, data): 492 super(ReadableTextFileObject, self).__init__(fs, path, StringIO.StringIO(data.decode("utf-8")))492 super(ReadableTextFileObject, self).__init__(fs, path, unicode_compatibility.UnicodeIO(unicode_compatibility.decode_for(data, unicode_compatibility.unicode))) 493 493 494 494 def close(self): -
trunk/Tools/Scripts/webkitpy/common/system/filesystem_mock_unittest.py
r181014 r250375 71 71 self.quick_check(self.fs.normpath, 72 72 self.fs._slow_but_correct_normpath, 73 '',74 '/',75 '.',76 '/.',77 'foo',78 'foo/',79 'foo/.',80 'foo/bar',81 '/foo',82 'foo/../bar',83 'foo/../bar/baz',84 '../foo')73 ('',), 74 ('/',), 75 ('.',), 76 ('/.',), 77 ('foo',), 78 ('foo/',), 79 ('foo/.',), 80 ('foo/bar',), 81 ('/foo',), 82 ('foo/../bar',), 83 ('foo/../bar/baz',), 84 ('../foo',)) 85 85 86 86 def test_dirs_under(self): … … 91 91 fs = filesystem_mock.MockFileSystem(files=FAKE_FILES) 92 92 93 self.assertEqual s(fs.dirs_under('/tests'), ['/tests', '/tests/test2', '/tests/test3', '/tests/test3/test2'])93 self.assertEqual(fs.dirs_under('/tests'), ['/tests', '/tests/test2', '/tests/test3', '/tests/test3/test2']) 94 94 95 95 def filter_dir(fs, dirpath): 96 96 return fs.basename(dirpath) != 'test2' 97 97 98 self.assertEqual s(fs.dirs_under('/tests', filter_dir), ['/tests', '/tests/test3'])98 self.assertEqual(fs.dirs_under('/tests', filter_dir), ['/tests', '/tests/test3']) -
trunk/Tools/Scripts/webkitpy/common/system/filesystem_unittest.py
r220150 r250375 38 38 import unittest 39 39 40 from filesystem import FileSystem40 from webkitpy.common.system.filesystem import FileSystem 41 41 42 42 … … 268 268 269 269 unicode_text_string = u'\u016An\u012Dc\u014Dde\u033D' 270 hex_equivalent = '\xC5\xAA\x6E\xC4\xAD\x63\xC5\x8D\x64\x65\xCC\xBD'271 malformed_text_hex = '\x4D\x69\x63\x72\x6F\x73\x6F\x66\x74\xAE\x20\x56\x69\x73\x75\x61\x6C\x20\x53\x74\x75\x64\x69\x6F\xAE\x20\x32\x30\x31\x30\x0D\x0A'272 malformed_ignored_text_hex = '\x4D\x69\x63\x72\x6F\x73\x6F\x66\x74\x20\x56\x69\x73\x75\x61\x6C\x20\x53\x74\x75\x64\x69\x6F\x20\x32\x30\x31\x30\x0D\x0A'270 hex_equivalent = b'\xC5\xAA\x6E\xC4\xAD\x63\xC5\x8D\x64\x65\xCC\xBD' 271 malformed_text_hex = b'\x4D\x69\x63\x72\x6F\x73\x6F\x66\x74\xAE\x20\x56\x69\x73\x75\x61\x6C\x20\x53\x74\x75\x64\x69\x6F\xAE\x20\x32\x30\x31\x30\x0D\x0A' 272 malformed_ignored_text_hex = b'\x4D\x69\x63\x72\x6F\x73\x6F\x66\x74\x20\x56\x69\x73\x75\x61\x6C\x20\x53\x74\x75\x64\x69\x6F\x20\x32\x30\x31\x30\x0D\x0A' 273 273 try: 274 274 text_path = tempfile.mktemp(prefix='tree_unittest_') … … 286 286 self.assertRaises(ValueError, fs.read_text_file, binary_path) 287 287 text_contents = fs.read_binary_file(binary_path).decode('utf8', 'ignore') 288 self.assertEquals(text_contents, malformed_ignored_text_hex) 289 fs.open_text_file_for_reading(binary_path, 'replace').readline() 288 self.assertEqual(text_contents, malformed_ignored_text_hex.decode('utf8', 'ignore')) 289 with fs.open_text_file_for_reading(binary_path, 'replace') as file: 290 file.readline() 290 291 291 292 finally: … … 312 313 raise WindowsError 313 314 except NameError: 314 raise FileSystem._WindowsError315 raise OSError 315 316 316 317 fs = FileSystem() -
trunk/Tools/Scripts/webkitpy/common/system/outputcapture.py
r226736 r250375 32 32 import sys 33 33 import unittest 34 from StringIO import StringIO 34 35 from webkitpy.common.unicode_compatibility import StringIO 35 36 36 37 -
trunk/Tools/Scripts/webkitpy/common/system/outputtee_unittest.py
r174136 r250375 27 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 28 29 import StringIO30 29 import unittest 31 30 32 31 from webkitpy.common.system.outputtee import Tee, OutputTee 32 from webkitpy.common.unicode_compatibility import StringIO 33 33 34 34 35 35 class SimpleTeeTest(unittest.TestCase): 36 36 def test_simple_tee(self): 37 file1, file2 = StringIO .StringIO(), StringIO.StringIO()37 file1, file2 = StringIO(), StringIO() 38 38 tee = Tee(file1, file2) 39 39 tee.write("foo bar\n") -
trunk/Tools/Scripts/webkitpy/common/system/path.py
r204408 r250375 36 36 import logging 37 37 import threading 38 import urllib 38 39 if sys.version_info > (3, 0): 40 from urllib.parse import quote as urllib_quote 41 else: 42 from urllib import quote as urllib_quote 39 43 40 44 _log = logging.getLogger(__name__) … … 147 151 # rules, we allow a small list of other characters through un-escaped. 148 152 # It's unclear if this is the best possible solution. 149 return urllib .quote(path, safe='/+:')153 return urllib_quote(path, safe='/+:') 150 154 151 155 -
trunk/Tools/Scripts/webkitpy/common/system/pemfile.py
r237727 r250375 123 123 try: 124 124 index = lines.index(end_marker) 125 except ValueError , e:125 except ValueError: 126 126 raise BadFormatError("Cannot find section end: {}".format(end_marker)) 127 127 -
trunk/Tools/Scripts/webkitpy/common/system/pemfile_unittest.py
r237727 r250375 24 24 25 25 import unittest 26 import sys27 26 28 27 from webkitpy.common.system.pemfile import Pem, BadFormatError 28 from webkitpy.common.system.platforminfo import PlatformInfo 29 29 30 30 … … 158 158 lines = docstring.expandtabs().splitlines() 159 159 # Determine minimum indentation (first line doesn't count): 160 indent = sys.maxint160 indent = PlatformInfo.MAX 161 161 for line in lines[1:]: 162 162 stripped = line.lstrip() … … 165 165 # Remove indentation (first line is special): 166 166 trimmed = [lines[0].strip()] 167 if indent < sys.maxint:167 if indent < PlatformInfo.MAX: 168 168 for line in lines[1:]: 169 169 trimmed.append(line[indent:].rstrip()) -
trunk/Tools/Scripts/webkitpy/common/system/platforminfo.py
r243030 r250375 37 37 38 38 class PlatformInfo(object): 39 MAX = 2147483647 40 39 41 """This class provides a consistent (and mockable) interpretation of 40 42 system-specific values (like sys.platform and platform.mac_ver()) … … 119 121 def total_bytes_memory(self): 120 122 if self.is_mac(): 121 return long(self._executive.run_command(["sysctl", "-n", "hw.memsize"]))123 return int(self._executive.run_command(["sysctl", "-n", "hw.memsize"])) 122 124 return None 123 125 124 126 def terminal_width(self): 125 """Returns sys.maxintif the width cannot be determined."""127 """Returns MAX if the width cannot be determined.""" 126 128 try: 127 129 if self.is_win(): … … 136 138 # automatically performs a line feed. 137 139 return right - left 138 return s ys.maxint140 return self.MAX 139 141 else: 140 142 import fcntl … … 145 147 return columns 146 148 except: 147 return s ys.maxint149 return self.MAX 148 150 149 151 def build_version(self): -
trunk/Tools/Scripts/webkitpy/common/system/platforminfo_unittest.py
r237836 r250375 77 77 # This test makes sure the real (unmocked) code actually works. 78 78 info = PlatformInfo(sys, platform, Executive()) 79 self.assertNotEqual s(info.os_name, '')79 self.assertNotEqual(info.os_name, '') 80 80 if info.is_mac() or info.is_win(): 81 81 self.assertIsNotNone(info.os_version) 82 self.assertNotEqual s(info.display_name(), '')82 self.assertNotEqual(info.display_name(), '') 83 83 self.assertTrue(info.is_mac() or info.is_win() or info.is_linux() or info.is_freebsd()) 84 84 self.assertIsNotNone(info.terminal_width()) … … 136 136 def test_display_name(self): 137 137 info = self.make_info(fake_sys('darwin')) 138 self.assertNotEqual s(info.display_name(), '')138 self.assertNotEqual(info.display_name(), '') 139 139 140 140 info = self.make_info(fake_sys('win32'), fake_platform(win_version_string='6.1.7600')) 141 self.assertNotEqual s(info.display_name(), '')141 self.assertNotEqual(info.display_name(), '') 142 142 143 143 info = self.make_info(fake_sys('linux2'), fake_platform('', '10.4')) 144 self.assertNotEqual s(info.display_name(), '')144 self.assertNotEqual(info.display_name(), '') 145 145 146 146 info = self.make_info(fake_sys('freebsd9'), fake_platform('', '9.0-RELEASE')) 147 self.assertNotEqual s(info.display_name(), '')147 self.assertNotEqual(info.display_name(), '') 148 148 149 149 def test_total_bytes_memory(self): -
trunk/Tools/Scripts/webkitpy/common/system/profiler.py
r225724 r250375 30 30 import logging 31 31 import re 32 import itertools 32 import sys 33 34 if sys.version_info < (3, 0): 35 from itertools import ifilter as filter 33 36 34 37 _log = logging.getLogger(__name__) … … 42 45 return None 43 46 profiler_name = profiler_name or cls.default_profiler_name(host.platform) 44 profiler_class = next( itertools.ifilter(lambda profiler: profiler.name == profiler_name, profilers), None)47 profiler_class = next(filter(lambda profiler: profiler.name == profiler_name, profilers), None) 45 48 if not profiler_class: 46 49 return None -
trunk/Tools/Scripts/webkitpy/common/system/profiler_unittest.py
r174136 r250375 32 32 from webkitpy.common.system.systemhost_mock import MockSystemHost 33 33 34 from .profiler import ProfilerFactory, GooglePProf34 from webkitpy.common.system.profiler import ProfilerFactory, GooglePProf 35 35 36 36 -
trunk/Tools/Scripts/webkitpy/common/system/stack_utils_unittest.py
r174136 r250375 35 35 36 36 def current_thread_id(): 37 thread_id, _ = sys._current_frames().items()[0] 38 return thread_id 37 for thread_id in sys._current_frames().keys(): 38 return thread_id 39 return None 39 40 40 41 -
trunk/Tools/Scripts/webkitpy/common/system/systemhost.py
r247228 r250375 32 32 import sys 33 33 34 from .import environment, executive, file_lock, filesystem, platforminfo, user, workspace34 from webkitpy.common.system import environment, executive, file_lock, filesystem, platforminfo, user, workspace 35 35 36 36 -
trunk/Tools/Scripts/webkitpy/common/system/user.py
r233332 r250375 37 37 import webbrowser 38 38 39 from .executive import Executive40 from .platforminfo import PlatformInfo39 from webkitpy.common.system.executive import Executive 40 from webkitpy.common.system.platforminfo import PlatformInfo 41 41 42 42 … … 50 50 # There is no readline module for win32, not much to do except cry. 51 51 _log.warn("Unable to import readline.") 52 53 if sys.version_info > (3, 0): 54 input_func = input 55 else: 56 input_func = raw_input 52 57 53 58 … … 63 68 # FIXME: These are @classmethods because bugzilla.py doesn't have a Tool object (thus no User instance). 64 69 @classmethod 65 def prompt(cls, message, repeat=1, raw_input= raw_input):70 def prompt(cls, message, repeat=1, raw_input=input_func): 66 71 response = None 67 72 while (repeat and not response): … … 75 80 76 81 @classmethod 77 def prompt_with_multiple_lists(cls, list_title, subtitles, lists, can_choose_multiple=False, raw_input= raw_input):82 def prompt_with_multiple_lists(cls, list_title, subtitles, lists, can_choose_multiple=False, raw_input=input_func): 78 83 item_index = 0 79 84 cumulated_list = [] … … 115 120 116 121 @classmethod 117 def prompt_with_list(cls, list_title, list_items, can_choose_multiple=False, raw_input= raw_input):122 def prompt_with_list(cls, list_title, list_items, can_choose_multiple=False, raw_input=input_func): 118 123 print(list_title) 119 124 i = 0 … … 157 162 pass 158 163 159 def confirm(self, message=None, default=DEFAULT_YES, raw_input= raw_input):164 def confirm(self, message=None, default=DEFAULT_YES, raw_input=input_func): 160 165 if not message: 161 166 message = "Continue?" -
trunk/Tools/Scripts/webkitpy/common/system/user_mock.py
r135912 r250375 28 28 29 29 import logging 30 import sys 30 31 31 32 _log = logging.getLogger(__name__) 33 34 if sys.version_info < (3, 0): 35 input = raw_input 32 36 33 37 … … 35 39 36 40 @classmethod 37 def prompt(cls, message, repeat=1, raw_input= raw_input):41 def prompt(cls, message, repeat=1, raw_input=input): 38 42 return "Mock user response" 39 43 40 44 @classmethod 41 def prompt_with_list(cls, list_title, list_items, can_choose_multiple=False, raw_input= raw_input):45 def prompt_with_list(cls, list_title, list_items, can_choose_multiple=False, raw_input=input): 42 46 pass 43 47 -
trunk/Tools/Scripts/webkitpy/common/version.py
r225953 r250375 34 34 def from_iterable(val): 35 35 result = Version() 36 for i in xrange(len(val)):36 for i in range(len(val)): 37 37 result[i] = int(val[i]) 38 38 return result … … 40 40 @staticmethod 41 41 def from_name(name): 42 from version_name_map import VersionNameMap42 from webkitpy.common.version_name_map import VersionNameMap 43 43 return VersionNameMap.map().from_name(name)[1] 44 44 … … 100 100 assert isinstance(version, Version) 101 101 does_match = True 102 for i in xrange(len(version)):102 for i in range(len(version)): 103 103 if self[i] != version[i]: 104 104 does_match = False … … 109 109 def __str__(self): 110 110 len_to_print = 1 111 for i in xrange(len(self)):111 for i in range(len(self)): 112 112 if self[i]: 113 113 len_to_print = i + 1 114 114 result = str(self.major) 115 for i in xrange(len_to_print - 1):115 for i in range(len_to_print - 1): 116 116 result += '.{}'.format(self[i + 1]) 117 117 return result … … 120 120 if other is None: 121 121 return 1 122 for i in xrange(len(self)): 123 if cmp(self[i], other[i]): 124 return cmp(self[i], other[i]) 122 for i in range(len(self)): 123 diff = self[i] - other[i] 124 if diff: 125 return diff 125 126 return 0 127 128 def __eq__(self, other): 129 return self.__cmp__(other) == 0 130 131 def __ne__(self, other): 132 return self.__cmp__(other) != 0 133 134 def __lt__(self, other): 135 return self.__cmp__(other) < 0 136 137 def __le__(self, other): 138 return self.__cmp__(other) <= 0 139 140 def __gt__(self, other): 141 return self.__cmp__(other) > 0 142 143 def __ge__(self, other): 144 return self.__cmp__(other) >= 0 -
trunk/Tools/Scripts/webkitpy/common/version_name_map.py
r250121 r250375 91 91 result = {} 92 92 assert minimum <= maximum 93 for i in xrange((maximum.major + 1) - minimum.major):93 for i in range((maximum.major + 1) - minimum.major): 94 94 result['{} {}'.format(prefix, str(Version(minimum.major + i)))] = Version(minimum.major + i) 95 95 return result … … 97 97 def to_name(self, version, platform=None, table=PUBLIC_TABLE): 98 98 closest_match = (None, None) 99 for os_name, os_version in self.mapping_for_platform(platform, table).ite ritems():99 for os_name, os_version in self.mapping_for_platform(platform, table).items(): 100 100 if version == os_version: 101 101 return os_name … … 127 127 def from_name(self, name): 128 128 # Exact match 129 for _, map in self.mapping.ite ritems():130 for os_name, os_map in map.ite ritems():129 for _, map in self.mapping.items(): 130 for os_name, os_map in map.items(): 131 131 if name in os_map: 132 132 return (os_name, os_map[name]) … … 134 134 # It's not an exact match, let's try unifying formatting 135 135 unformatted = self.strip_name_formatting(name) 136 for _, map in self.mapping.ite ritems():137 for os_name, os_map in map.ite ritems():138 for version_name, version in os_map.ite ritems():136 for _, map in self.mapping.items(): 137 for os_name, os_map in map.items(): 138 for version_name, version in os_map.items(): 139 139 if self.strip_name_formatting(version_name) == unformatted: 140 140 return (os_name, version) -
trunk/Tools/Scripts/webkitpy/common/version_name_map_unittest.py
r246497 r250375 25 25 from webkitpy.common.system.systemhost import SystemHost 26 26 from webkitpy.common.version import Version 27 from version_name_map import VersionNameMap27 from webkitpy.common.version_name_map import VersionNameMap 28 28 29 29 -
trunk/Tools/Scripts/webkitpy/common/version_unittest.py
r225953 r250375 23 23 import unittest 24 24 25 from version import Version25 from webkitpy.common.version import Version 26 26 27 27 -
trunk/Tools/Scripts/webkitpy/common/wavediff.py
r181579 r250375 21 21 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 22 23 import StringIO24 23 import struct 25 24 import sys 26 25 import tempfile 27 26 import wave 27 28 from io import BytesIO 28 29 29 30 … … 38 39 waveFile1 = wave.open(in1, 'rb') 39 40 else: 40 waveFile1 = wave.open( StringIO.StringIO(in1), 'rb')41 waveFile1 = wave.open(BytesIO(in1), 'rb') 41 42 if isinstance(in2, file): 42 43 waveFile1 = wave.open(in2, 'rb') 43 44 else: 44 waveFile2 = wave.open( StringIO.StringIO(in2), 'rb')45 waveFile2 = wave.open(BytesIO(in2), 'rb') 45 46 46 47 params1 = waveFile1.getparams() -
trunk/Tools/Scripts/webkitpy/port/__init__.py
r136545 r250375 29 29 """Port-specific entrypoints for the layout tests test infrastructure.""" 30 30 31 import builders # Why is this in port?31 import webkitpy.port.builders # Why is this in port? 32 32 33 from base import Port # It's possible we don't need to export this virtual baseclass outside the module.34 from driver import Driver, DriverInput, DriverOutput35 from factory import platform_options, configuration_options33 from webkitpy.port.base import Port # It's possible we don't need to export this virtual baseclass outside the module. 34 from webkitpy.port.driver import Driver, DriverInput, DriverOutput 35 from webkitpy.port.factory import platform_options, configuration_options
Note: See TracChangeset
for help on using the changeset viewer.