Changeset 58023 in webkit
- Timestamp:
- Apr 21, 2010 4:22:15 PM (14 years ago)
- Location:
- trunk/WebKitTools
- Files:
-
- 47 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKitTools/ChangeLog
r58020 r58023 1 2010-04-21 Eric Seidel <eric@webkit.org> 2 3 Unreviewed. Rolling out unicode() changes as they broke NRWT for chromium. 4 Rolling out: 5 http://trac.webkit.org/changeset/58014 6 http://trac.webkit.org/changeset/58016 7 http://trac.webkit.org/changeset/58020 8 9 REGRESSION(57531): the commit-queue still hates Tor Arne Vestbo 10 https://bugs.webkit.org/show_bug.cgi?id=37765 11 12 * Scripts/webkitpy/common/checkout/api_unittest.py: 13 * Scripts/webkitpy/common/checkout/changelog.py: 14 * Scripts/webkitpy/common/checkout/changelog_unittest.py: 15 * Scripts/webkitpy/common/checkout/commitinfo.py: 16 * Scripts/webkitpy/common/checkout/scm.py: 17 * Scripts/webkitpy/common/checkout/scm_unittest.py: 18 * Scripts/webkitpy/common/config/committers.py: 19 * Scripts/webkitpy/common/net/bugzilla.py: 20 * Scripts/webkitpy/common/net/buildbot.py: 21 * Scripts/webkitpy/common/net/buildbot_unittest.py: 22 * Scripts/webkitpy/common/net/statusserver.py: 23 * Scripts/webkitpy/common/prettypatch.py: 24 * Scripts/webkitpy/common/system/autoinstall.py: 25 * Scripts/webkitpy/common/system/deprecated_logging.py: 26 * Scripts/webkitpy/common/system/executive.py: 27 * Scripts/webkitpy/common/system/executive_unittest.py: 28 * Scripts/webkitpy/layout_tests/layout_package/dump_render_tree_thread.py: 29 * Scripts/webkitpy/layout_tests/layout_package/json_results_generator.py: 30 * Scripts/webkitpy/layout_tests/port/apache_http_server.py: 31 * Scripts/webkitpy/layout_tests/port/chromium.py: 32 * Scripts/webkitpy/layout_tests/port/chromium_linux.py: 33 * Scripts/webkitpy/layout_tests/port/chromium_mac.py: 34 * Scripts/webkitpy/layout_tests/port/gtk.py: 35 * Scripts/webkitpy/layout_tests/port/mac.py: 36 * Scripts/webkitpy/layout_tests/port/mac_unittest.py: 37 * Scripts/webkitpy/layout_tests/port/qt.py: 38 * Scripts/webkitpy/layout_tests/port/server_process.py: 39 * Scripts/webkitpy/layout_tests/port/webkit.py: 40 * Scripts/webkitpy/layout_tests/port/websocket_server.py: 41 * Scripts/webkitpy/layout_tests/rebaseline_chromium_webkit_tests.py: 42 * Scripts/webkitpy/layout_tests/run_webkit_tests.py: 43 * Scripts/webkitpy/layout_tests/test_types/image_diff.py: 44 * Scripts/webkitpy/layout_tests/test_types/test_type_base.py: 45 * Scripts/webkitpy/layout_tests/test_types/text_diff.py: 46 * Scripts/webkitpy/style/filereader_unittest.py: 47 * Scripts/webkitpy/thirdparty/__init__.py: 48 * Scripts/webkitpy/tool/commands/earlywarningsystem.py: 49 * Scripts/webkitpy/tool/commands/queues.py: 50 * Scripts/webkitpy/tool/commands/queues_unittest.py: 51 * Scripts/webkitpy/tool/commands/upload.py: 52 * Scripts/webkitpy/tool/mocktool.py: 53 * Scripts/webkitpy/tool/steps/abstractstep.py: 54 * Scripts/webkitpy/tool/steps/postdiff.py: 55 * Scripts/webkitpy/tool/steps/postdiffforcommit.py: 56 * Scripts/webkitpy/tool/steps/postdiffforrevert.py: 57 * Scripts/webkitpy/tool/steps/steps_unittest.py: 58 1 59 2010-04-21 Eric Seidel <eric@webkit.org> 2 60 -
trunk/WebKitTools/Scripts/webkitpy/common/checkout/api_unittest.py
r58014 r58023 27 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 28 29 from __future__ import with_statement30 31 import codecs32 29 import os 33 30 import shutil … … 41 38 from webkitpy.thirdparty.mock import Mock 42 39 43 44 40 # FIXME: Copied from scm_unittest.py 45 def write_into_file_at_path(file_path, contents, encoding="utf-8"): 46 with codecs.open(file_path, "w", encoding) as file: 47 file.write(contents) 41 def write_into_file_at_path(file_path, contents): 42 new_file = open(file_path, 'w') 43 new_file.write(contents) 44 new_file.close() 48 45 49 46 50 _changelog1entry1 = u"""2010-03-25 Tor Arne Vestb\u00f8 <vestbo@webkit.org>47 _changelog1entry1 = """2010-03-25 Eric Seidel <eric@webkit.org> 51 48 52 49 Unreviewed build fix to un-break webkit-patch land. … … 57 54 * Scripts/webkitpy/common/checkout/api.py: import scm.CommitMessage 58 55 """ 59 _changelog1entry2 = u"""2010-03-25 Adam Barth <abarth@webkit.org>56 _changelog1entry2 = """2010-03-25 Adam Barth <abarth@webkit.org> 60 57 61 58 Reviewed by Eric Seidel. … … 66 63 * Scripts/webkitpy/common/checkout/api.py: 67 64 """ 68 _changelog1 = u"\n".join([_changelog1entry1, _changelog1entry2])69 _changelog2 = u"""2010-03-25 Tor Arne Vestb\u00f8 <vestbo@webkit.org>65 _changelog1 = "\n".join([_changelog1entry1, _changelog1entry2]) 66 _changelog2 = """2010-03-25 Eric Seidel <eric@webkit.org> 70 67 71 68 Unreviewed build fix to un-break webkit-patch land. … … 83 80 84 81 class CommitMessageForThisCommitTest(unittest.TestCase): 85 expected_commit_message = u"""2010-03-25 Tor Arne Vestb\u00f8 <vestbo@webkit.org>82 expected_commit_message = """2010-03-25 Eric Seidel <eric@webkit.org> 86 83 87 84 Unreviewed build fix to un-break webkit-patch land. … … 91 88 92 89 * Scripts/webkitpy/common/checkout/api.py: import scm.CommitMessage 93 2010-03-25 Tor Arne Vestb\u00f8 <vestbo@webkit.org>90 2010-03-25 Eric Seidel <eric@webkit.org> 94 91 95 92 Unreviewed build fix to un-break webkit-patch land. … … 141 138 commitinfo = checkout.commit_info_for_revision(4) 142 139 self.assertEqual(commitinfo.bug_id(), 36629) 143 self.assertEqual(commitinfo.author_name(), u"Tor Arne Vestb\u00f8")144 self.assertEqual(commitinfo.author_email(), " vestbo@webkit.org")140 self.assertEqual(commitinfo.author_name(), "Eric Seidel") 141 self.assertEqual(commitinfo.author_email(), "eric@webkit.org") 145 142 self.assertEqual(commitinfo.reviewer_text(), None) 146 143 self.assertEqual(commitinfo.reviewer(), None) -
trunk/WebKitTools/Scripts/webkitpy/common/checkout/changelog.py
r58014 r58023 100 100 @staticmethod 101 101 def parse_latest_entry_from_file(changelog_file): 102 """changelog_file must be a file-like object which returns103 unicode strings. Use codecs.open or StringIO(unicode())104 to pass file objects to this class."""105 102 date_line_regexp = re.compile(ChangeLogEntry.date_line_regexp) 106 103 entry_lines = [] 107 104 # The first line should be a date line. 108 105 first_line = changelog_file.readline() 109 assert(isinstance(first_line, unicode))110 106 if not date_line_regexp.match(first_line): 111 107 return None -
trunk/WebKitTools/Scripts/webkitpy/common/checkout/changelog_unittest.py
r58014 r58023 27 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 28 29 from __future__ import with_statement 30 31 import codecs 29 import unittest 32 30 import os 33 31 import tempfile 34 import unittest35 32 36 33 from StringIO import StringIO … … 56 53 57 54 # More example text than we need. Eventually we need to support parsing this all and write tests for the parsing. 58 _example_changelog = u"""2009-08-17 Tor Arne Vestb\xf8 <vestbo@webkit.org>55 _example_changelog = '''2009-08-17 David Kilzer <ddkilzer@apple.com> 59 56 60 57 <http://webkit.org/b/28393> check-webkit-style: add check for use of std::max()/std::min() instead of MAX()/MIN() … … 88 85 89 86 == Rolled over to ChangeLog-2009-06-16 == 90 """ 87 ''' 91 88 92 89 def test_latest_entry_parse(self): 93 changelog_contents = u"%s\n%s" % (self._example_entry, self._example_changelog)90 changelog_contents = "%s\n%s" % (self._example_entry, self._example_changelog) 94 91 changelog_file = StringIO(changelog_contents) 95 92 latest_entry = ChangeLog.parse_latest_entry_from_file(changelog_file) … … 101 98 102 99 @staticmethod 103 def _write_tmp_file_with_contents(byte_array): 104 assert(isinstance(byte_array, str)) 100 def _write_tmp_file_with_contents(contents): 105 101 (file_descriptor, file_path) = tempfile.mkstemp() # NamedTemporaryFile always deletes the file on close in python < 2.6 106 with os.fdopen(file_descriptor, "w") as file: 107 file.write(byte_array) 102 file = os.fdopen(file_descriptor, 'w') 103 file.write(contents) 104 file.close() 108 105 return file_path 109 106 110 107 @staticmethod 111 def _read_file_contents(file_path, encoding): 112 with codecs.open(file_path, "r", encoding) as file: 113 return file.read() 108 def _read_file_contents(file_path): 109 file = open(file_path) 110 contents = file.read() 111 file.close() 112 return contents 114 113 115 114 _new_entry_boilerplate = '''2009-08-19 Eric Seidel <eric@webkit.org> … … 123 122 124 123 def test_set_reviewer(self): 125 changelog_contents = u"%s\n%s" % (self._new_entry_boilerplate, self._example_changelog)126 changelog_path = self._write_tmp_file_with_contents(changelog_contents .encode("utf-8"))124 changelog_contents = "%s\n%s" % (self._new_entry_boilerplate, self._example_changelog) 125 changelog_path = self._write_tmp_file_with_contents(changelog_contents) 127 126 reviewer_name = 'Test Reviewer' 128 127 ChangeLog(changelog_path).set_reviewer(reviewer_name) 129 actual_contents = self._read_file_contents(changelog_path , "utf-8")128 actual_contents = self._read_file_contents(changelog_path) 130 129 expected_contents = changelog_contents.replace('NOBODY (OOPS!)', reviewer_name) 131 130 os.remove(changelog_path) … … 171 170 172 171 def _assert_update_for_revert_output(self, args, expected_entry): 173 changelog_contents = u"%s\n%s" % (self._new_entry_boilerplate, self._example_changelog)174 changelog_path = self._write_tmp_file_with_contents(changelog_contents .encode("utf-8"))172 changelog_contents = "%s\n%s" % (self._new_entry_boilerplate, self._example_changelog) 173 changelog_path = self._write_tmp_file_with_contents(changelog_contents) 175 174 changelog = ChangeLog(changelog_path) 176 175 changelog.update_for_revert(*args) -
trunk/WebKitTools/Scripts/webkitpy/common/checkout/commitinfo.py
r58014 r58023 28 28 # 29 29 # WebKit's python module for holding information on a commit 30 31 import StringIO 30 32 31 33 from webkitpy.common.checkout.changelog import view_source_url -
trunk/WebKitTools/Scripts/webkitpy/common/checkout/scm.py
r58014 r58023 146 146 147 147 def strip_r_from_svn_revision(self, svn_revision): 148 match = re.match("^r(?P<svn_revision>\d+)", unicode(svn_revision))148 match = re.match("^r(?P<svn_revision>\d+)", svn_revision) 149 149 if (match): 150 150 return match.group('svn_revision') … … 345 345 def changed_files_for_revision(self, revision): 346 346 # As far as I can tell svn diff --summarize output looks just like svn status output. 347 status_command = ["svn", "diff", "--summarize", "-c", revision]347 status_command = ["svn", "diff", "--summarize", "-c", str(revision)] 348 348 return self.run_status_and_extract_filenames(status_command, self._status_regexp("ACDMR")) 349 349 … … 362 362 363 363 def create_patch(self): 364 return run_command( [self.script_path("svn-create-patch")], cwd=self.checkout_root, return_stderr=False)364 return run_command(self.script_path("svn-create-patch"), cwd=self.checkout_root, return_stderr=False) 365 365 366 366 def committer_email_for_revision(self, revision): 367 return run_command(["svn", "propget", "svn:author", "--revprop", "-r", revision]).rstrip()367 return run_command(["svn", "propget", "svn:author", "--revprop", "-r", str(revision)]).rstrip() 368 368 369 369 def contents_at_revision(self, path, revision): 370 370 remote_path = "%s/%s" % (self._repository_url(), path) 371 return run_command(["svn", "cat", "-r", revision, remote_path])371 return run_command(["svn", "cat", "-r", str(revision), remote_path]) 372 372 373 373 def diff_for_revision(self, revision): 374 374 # FIXME: This should probably use cwd=self.checkout_root 375 return run_command(['svn', 'diff', '-c', revision])375 return run_command(['svn', 'diff', '-c', str(revision)]) 376 376 377 377 def _repository_url(self): … … 406 406 407 407 def svn_commit_log(self, svn_revision): 408 svn_revision = self.strip_r_from_svn_revision(s vn_revision)408 svn_revision = self.strip_r_from_svn_revision(str(svn_revision)) 409 409 return run_command(['svn', 'log', '--non-interactive', '--revision', svn_revision]); 410 410 -
trunk/WebKitTools/Scripts/webkitpy/common/checkout/scm_unittest.py
r58014 r58023 28 28 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 29 30 from __future__ import with_statement31 32 30 import base64 33 import codecs34 31 import getpass 35 32 import os … … 60 57 raise ScriptError('Failed to run "%s" exit_code: %d cwd: %s' % (args, exit_code, cwd)) 61 58 62 63 def write_into_file_at_path(file_path, contents, encoding="utf-8"): 64 with codecs.open(file_path, "w", encoding) as file:65 file.write(contents)66 67 68 def read_from_path(file_path, encoding="utf-8"): 69 with codecs.open(file_path, "r", encoding) as file:70 return file.read()71 59 def write_into_file_at_path(file_path, contents): 60 file = open(file_path, 'w') 61 file.write(contents) 62 file.close() 63 64 def read_from_path(file_path): 65 file = open(file_path, 'r') 66 contents = file.read() 67 file.close() 68 return contents 72 69 73 70 # Exists to share svn repository creation code between the git and svn tests … … 312 309 """ 313 310 self.checkout.apply_patch(self._create_patch(git_binary_addition)) 314 added = read_from_path('fizzbuzz7.gif' , encoding=None)311 added = read_from_path('fizzbuzz7.gif') 315 312 self.assertEqual(512, len(added)) 316 313 self.assertTrue(added.startswith('GIF89a')) … … 340 337 """ 341 338 self.checkout.apply_patch(self._create_patch(git_binary_modification)) 342 modified = read_from_path('fizzbuzz7.gif' , encoding=None)339 modified = read_from_path('fizzbuzz7.gif') 343 340 self.assertEqual('foobar\n', modified) 344 341 self.assertTrue('fizzbuzz7.gif' in self.scm.changed_files()) … … 522 519 patch_file = self._create_patch(patch_contents) 523 520 self.checkout.apply_patch(patch_file) 524 actual_contents = read_from_path("test_file.swf" , encoding=None)521 actual_contents = read_from_path("test_file.swf") 525 522 self.assertEqual(actual_contents, expected_contents) 526 523 … … 743 740 test_file_path = os.path.join(self.git_checkout_path, test_file_name) 744 741 file_contents = ''.join(map(chr, range(256))) 745 write_into_file_at_path(test_file_path, file_contents , encoding=None)742 write_into_file_at_path(test_file_path, file_contents) 746 743 run_command(['git', 'add', test_file_name]) 747 744 patch = scm.create_patch() … … 753 750 self._setup_webkittools_scripts_symlink(scm) 754 751 self.checkout.apply_patch(self._create_patch(patch)) 755 self.assertEqual(file_contents, read_from_path(test_file_path , encoding=None))752 self.assertEqual(file_contents, read_from_path(test_file_path)) 756 753 757 754 # Check if we can create a patch from a local commit. 758 write_into_file_at_path(test_file_path, file_contents , encoding=None)755 write_into_file_at_path(test_file_path, file_contents) 759 756 run_command(['git', 'add', test_file_name]) 760 757 run_command(['git', 'commit', '-m', 'binary diff']) -
trunk/WebKitTools/Scripts/webkitpy/common/config/committers.py
r58014 r58023 241 241 Reviewer("Tim Omernick", "timo@apple.com"), 242 242 Reviewer("Timothy Hatcher", ["timothy@hatcher.name", "timothy@apple.com"], "xenon"), 243 Reviewer(u "Tor Arne Vestb\u00f8", "vestbo@webkit.org", "torarne"),243 Reviewer(u'Tor Arne Vestb\xf8', "vestbo@webkit.org", "torarne"), 244 244 Reviewer("Vicki Murley", "vicki@apple.com"), 245 245 Reviewer("Xan Lopez", ["xan.lopez@gmail.com", "xan@gnome.org", "xan@webkit.org"], "xan"), -
trunk/WebKitTools/Scripts/webkitpy/common/net/bugzilla.py
r58014 r58023 33 33 import os.path 34 34 import re 35 import StringIO36 35 import subprocess 37 36 … … 429 428 attachment[result_key] = flag['setter'] 430 429 431 def _string_contents(self, soup):432 # WebKit's bugzilla instance uses UTF-8.433 # BeautifulSoup always returns Unicode strings, however434 # the .string method returns a (unicode) NavigableString.435 # NavigableString can confuse other parts of the code, so we436 # convert from NavigableString to a real unicode() object using unicode().437 return unicode(soup.string)438 439 430 def _parse_attachment_element(self, element, bug_id): 440 441 431 attachment = {} 442 432 attachment['bug_id'] = bug_id … … 446 436 # FIXME: No need to parse out the url here. 447 437 attachment['url'] = self.attachment_url_for_id(attachment['id']) 448 attachment['name'] = self._string_contents(element.find('desc'))449 attachment['attacher_email'] = s elf._string_contents(element.find('attacher'))450 attachment['type'] = s elf._string_contents(element.find('type'))438 attachment['name'] = unicode(element.find('desc').string) 439 attachment['attacher_email'] = str(element.find('attacher').string) 440 attachment['type'] = str(element.find('type').string) 451 441 self._parse_attachment_flag( 452 442 element, 'review', attachment, 'reviewer_email') … … 459 449 bug = {} 460 450 bug["id"] = int(soup.find("bug_id").string) 461 bug["title"] = self._string_contents(soup.find("short_desc"))462 bug["reporter_email"] = s elf._string_contents(soup.find("reporter"))463 bug["assigned_to_email"] = s elf._string_contents(soup.find("assigned_to"))464 bug["cc_emails"] = [s elf._string_contents(element)451 bug["title"] = unicode(soup.find("short_desc").string) 452 bug["reporter_email"] = str(soup.find("reporter").string) 453 bug["assigned_to_email"] = str(soup.find("assigned_to").string) 454 bug["cc_emails"] = [str(element.string) 465 455 for element in soup.findAll('cc')] 466 456 bug["attachments"] = [self._parse_attachment_element(element, bug["id"]) for element in soup.findAll('attachment')] … … 559 549 def _fill_attachment_form(self, 560 550 description, 561 diff,551 patch_file_object, 562 552 comment_text=None, 563 553 mark_for_review=False, … … 579 569 else: 580 570 patch_name ="%s.patch" % timestamp() 581 582 # ClientForm expects a file-like object583 patch_file_object = StringIO.StringIO(diff.encode("utf-8"))584 571 self.browser.add_file(patch_file_object, 585 572 "text/plain", … … 589 576 def add_patch_to_bug(self, 590 577 bug_id, 591 diff,578 patch_file_object, 592 579 description, 593 580 comment_text=None, … … 608 595 self.bug_server_url, bug_id)) 609 596 self.browser.select_form(name="entryform") 610 611 597 self._fill_attachment_form(description, 612 diff,598 patch_file_object, 613 599 mark_for_review=mark_for_review, 614 600 mark_for_commit_queue=mark_for_commit_queue, … … 643 629 bug_description, 644 630 component=None, 645 diff=None,631 patch_file_object=None, 646 632 patch_description=None, 647 633 cc=None, … … 668 654 self.browser["cc"] = cc 669 655 if blocked: 670 self.browser["blocked"] = unicode(blocked)656 self.browser["blocked"] = str(blocked) 671 657 self.browser["short_desc"] = bug_title 672 658 self.browser["comment"] = bug_description 673 659 674 if diff:660 if patch_file_object: 675 661 self._fill_attachment_form( 676 662 patch_description, 677 diff,663 patch_file_object, 678 664 mark_for_review=mark_for_review, 679 665 mark_for_commit_queue=mark_for_commit_queue) -
trunk/WebKitTools/Scripts/webkitpy/common/net/buildbot.py
r58014 r58023 45 45 class Builder(object): 46 46 def __init__(self, name, buildbot): 47 self._name = name47 self._name = unicode(name) 48 48 self._buildbot = buildbot 49 49 self._builds_cache = {} … … 224 224 tables = BeautifulSoup(page).findAll("table") 225 225 for table in tables: 226 table_title = unicode(table.findPreviousSibling("p").string)226 table_title = table.findPreviousSibling("p").string 227 227 if table_title not in cls.expected_keys: 228 228 # This Exception should only ever be hit if run-webkit-tests changes its results.html format. 229 raise Exception("Unhandled title: %s" % table_title)229 raise Exception("Unhandled title: %s" % str(table_title)) 230 230 # We might want to translate table titles into identifiers before storing. 231 parsed_results[table_title] = [ unicode(row.find("a").string)for row in table.findAll("tr")]231 parsed_results[table_title] = [row.find("a").string for row in table.findAll("tr")] 232 232 233 233 return parsed_results … … 362 362 # First cell is the name 363 363 name_link = status_cells[0].find('a') 364 builder["name"] = unicode(name_link.string)364 builder["name"] = name_link.string 365 365 366 366 self._parse_last_build_cell(builder, status_cells[1]) … … 411 411 412 412 def _parse_twisted_file_row(self, file_row): 413 string_or_empty = lambda s oup: unicode(soup.string) if soup.string else u""413 string_or_empty = lambda string: str(string) if string else "" 414 414 file_cells = file_row.findAll('td') 415 415 return { 416 "filename" : string_or_empty(file_cells[0].find("a")),417 "size" : string_or_empty(file_cells[1]),418 "type" : string_or_empty(file_cells[2]),419 "encoding" : string_or_empty(file_cells[3]),416 "filename" : string_or_empty(file_cells[0].find("a").string), 417 "size" : string_or_empty(file_cells[1].string), 418 "type" : string_or_empty(file_cells[2].string), 419 "encoding" : string_or_empty(file_cells[3].string), 420 420 } 421 421 -
trunk/WebKitTools/Scripts/webkitpy/common/net/buildbot_unittest.py
r58014 r58023 52 52 def setUp(self): 53 53 self.buildbot = BuildBot() 54 self.builder = Builder( u"Test Builder \u2661", self.buildbot)54 self.builder = Builder("Test Builder", self.buildbot) 55 55 self._install_fetch_build(lambda build_number: ["test1", "test2"]) 56 56 -
trunk/WebKitTools/Scripts/webkitpy/common/net/statusserver.py
r58014 r58023 53 53 return 54 54 if patch.bug_id(): 55 self.browser["bug_id"] = unicode(patch.bug_id())55 self.browser["bug_id"] = str(patch.bug_id()) 56 56 if patch.id(): 57 self.browser["patch_id"] = unicode(patch.id())57 self.browser["patch_id"] = str(patch.id()) 58 58 59 59 def _add_results_file(self, results_file): … … 80 80 self.browser.open(update_svn_revision_url) 81 81 self.browser.select_form(name="update_svn_revision") 82 self.browser["number"] = unicode(svn_revision_number)82 self.browser["number"] = str(svn_revision_number) 83 83 self.browser["broken_bot"] = broken_bot 84 84 return self.browser.submit().read() -
trunk/WebKitTools/Scripts/webkitpy/common/prettypatch.py
r58014 r58023 39 39 pretty_diff = self.pretty_diff(diff) 40 40 diff_file = tempfile.NamedTemporaryFile(suffix=".html") 41 diff_file.write(pretty_diff .encode("utf-8"))41 diff_file.write(pretty_diff) 42 42 diff_file.flush() 43 43 return diff_file -
trunk/WebKitTools/Scripts/webkitpy/common/system/autoinstall.py
r58014 r58023 31 31 """Support for automatically downloading Python packages from an URL.""" 32 32 33 34 from __future__ import with_statement35 36 import codecs37 33 import logging 38 34 import new … … 119 115 os.makedirs(path) 120 116 121 def _write_file(self, path, text , encoding):117 def _write_file(self, path, text): 122 118 """Create a file at the given path with given text. 123 119 … … 127 123 _log.debug("Creating file...") 128 124 _log.debug(' "%s"' % path) 129 with codecs.open(path, "w", encoding) as file: 125 file = open(path, "w") 126 try: 130 127 file.write(text) 128 finally: 129 file.close() 131 130 132 131 def _set_up_target_dir(self, target_dir, append_to_search_path, … … 156 155 text = ("# This file is required for Python to search this " 157 156 "directory for modules.\n") 158 self._write_file(init_path, text , "ascii")157 self._write_file(init_path, text) 159 158 160 159 def _create_scratch_directory_inner(self, prefix): … … 218 217 return False 219 218 220 with codecs.open(version_path, "r", "utf-8") as file: 219 file = open(version_path, "r") 220 try: 221 221 version = file.read() 222 finally: 223 file.close() 222 224 223 225 return version.strip() == url.strip() … … 230 232 _log.debug(' To: "%s"' % version_path) 231 233 232 self._write_file(version_path, url , "utf-8")234 self._write_file(version_path, url) 233 235 234 236 def _extract_targz(self, path, scratch_dir): … … 283 285 284 286 try: 285 # We open this file w/o encoding, as we're reading/writing286 # the raw byte-stream from the zip file.287 287 outfile = open(path, 'wb') 288 288 except IOError, err: -
trunk/WebKitTools/Scripts/webkitpy/common/system/deprecated_logging.py
r58014 r58023 31 31 # This module is now deprecated in favor of python's built-in logging.py. 32 32 33 import codecs34 33 import os 35 34 import sys 36 37 35 38 36 def log(string): 39 37 print >> sys.stderr, string 40 38 41 42 39 def error(string): 43 40 log("ERROR: %s" % string) 44 41 exit(1) 45 46 42 47 43 # Simple class to split output between multiple destinations … … 50 46 self.files = files 51 47 52 # Callers should pass an already encoded string for writing. 53 def write(self, bytes): 48 def write(self, string): 54 49 for file in self.files: 55 file.write(bytes) 56 50 file.write(string) 57 51 58 52 class OutputTee: … … 78 72 if log_directory and not os.path.exists(log_directory): 79 73 os.makedirs(log_directory) 80 return codecs.open(log_path, "a+", "utf-8")74 return open(log_path, 'a+') 81 75 82 76 def _tee_outputs_to_files(self, files): -
trunk/WebKitTools/Scripts/webkitpy/common/system/executive.py
r58014 r58023 89 89 90 90 def _run_command_with_teed_output(self, args, teed_output): 91 args = map(unicode, args) # Popen will throw an exception if args are non-strings (like int())92 91 child_process = subprocess.Popen(args, 93 92 stdout=subprocess.PIPE, … … 101 100 if output_line == "" and child_process.poll() != None: 102 101 return child_process.poll() 103 # We assume that the child process wrote to us in utf-8,104 # so no re-encoding is necessary before writing here.105 102 teed_output.write(output_line) 106 103 107 # FIXME: Remove this deprecated method and move callers to run_command. 108 # FIXME: This method is a hack to allow running command which both 109 # capture their output and print out to stdin. Useful for things 110 # like "build-webkit" where we want to display to the user that we're building 111 # but still have the output to stuff into a log file. 112 def run_and_throw_if_fail(self, args, quiet=False, decode_output=True): 104 def run_and_throw_if_fail(self, args, quiet=False): 113 105 # Cache the child's output locally so it can be used for error reports. 114 106 child_out_file = StringIO.StringIO() 115 107 tee_stdout = sys.stdout 116 108 if quiet: 117 dev_null = open(os.devnull, "w") # FIXME: Does this need an encoding?109 dev_null = open(os.devnull, "w") 118 110 tee_stdout = dev_null 119 111 child_stdout = tee(child_out_file, tee_stdout) … … 124 116 child_output = child_out_file.getvalue() 125 117 child_out_file.close() 126 127 # We assume the child process output utf-8128 if decode_output:129 child_output = child_output.decode("utf-8")130 118 131 119 if exit_code: … … 158 146 # using Cygwin, it worked fine. We should investigate whether 159 147 # we need this platform specific code here. 160 subprocess.call(('taskkill.exe', '/f', '/pid', unicode(pid)),148 subprocess.call(('taskkill.exe', '/f', '/pid', str(pid)), 161 149 stdin=open(os.devnull, 'r'), 162 150 stdout=subprocess.PIPE, … … 176 164 pass 177 165 178 def _compute_stdin(self, input): 179 """Returns (stdin, string_to_communicate)""" 180 if not input: 181 return (None, None) 182 if hasattr(input, "read"): # Check if the input is a file. 183 return (input, None) # Assume the file is in the right encoding. 184 185 # Popen in Python 2.5 and before does not automatically encode unicode objects. 186 # http://bugs.python.org/issue5290 187 # See https://bugs.webkit.org/show_bug.cgi?id=37528 188 # for an example of a regresion caused by passing a unicode string directly. 189 # FIXME: We may need to encode differently on different platforms. 190 if isinstance(input, unicode): 191 input = input.encode("utf-8") 192 return (subprocess.PIPE, input) 193 194 # FIXME: run_and_throw_if_fail should be merged into this method. 166 # FIXME: This should be merged with run_and_throw_if_fail 167 195 168 def run_command(self, 196 169 args, … … 199 172 error_handler=None, 200 173 return_exit_code=False, 201 return_stderr=True, 202 decode_output=True): 203 args = map(unicode, args) # Popen will throw an exception if args are non-strings (like int()) 204 stdin, string_to_communicate = self._compute_stdin(input) 205 stderr = subprocess.STDOUT if return_stderr else None 174 return_stderr=True): 175 if hasattr(input, 'read'): # Check if the input is a file. 176 stdin = input 177 string_to_communicate = None 178 else: 179 stdin = None 180 if input: 181 stdin = subprocess.PIPE 182 # string_to_communicate seems to need to be a str for proper 183 # communication with shell commands. 184 # See https://bugs.webkit.org/show_bug.cgi?id=37528 185 # For an example of a regresion caused by passing a unicode string through. 186 string_to_communicate = str(input) 187 if return_stderr: 188 stderr = subprocess.STDOUT 189 else: 190 stderr = None 206 191 207 192 process = subprocess.Popen(args, … … 211 196 cwd=cwd) 212 197 output = process.communicate(string_to_communicate)[0] 213 # run_command automatically decodes to unicode() unless explicitly told not to.214 if decode_output:215 output = output.decode("utf-8")216 198 exit_code = process.wait() 217 199 -
trunk/WebKitTools/Scripts/webkitpy/common/system/executive_unittest.py
r58014 r58023 1 # Copyright (C) 20 10Google Inc. All rights reserved.1 # Copyright (C) 2009 Google Inc. All rights reserved. 2 2 # Copyright (C) 2009 Daniel Bates (dbates@intudata.com). All rights reserved. 3 3 # … … 32 32 from webkitpy.common.system.executive import Executive, run_command 33 33 34 35 34 class ExecutiveTest(unittest.TestCase): 36 35 … … 40 39 self.failUnlessRaises(OSError, run_bad_command) 41 40 42 def test_run_command_with_unicode(self): 43 """Validate that it is safe to pass unicode() objects 44 to Executive.run* methods, and they will return unicode() 45 objects by default unless decode_output=False""" 46 executive = Executive() 47 unicode_tor = u"WebKit \u2661 Tor Arne Vestb\u00F8!" 48 utf8_tor = unicode_tor.encode("utf-8") 49 50 output = executive.run_command(["cat"], input=unicode_tor) 51 self.assertEquals(output, unicode_tor) 52 53 output = executive.run_command(["echo", "-n", unicode_tor]) 54 self.assertEquals(output, unicode_tor) 55 56 output = executive.run_command(["echo", "-n", unicode_tor], decode_output=False) 57 self.assertEquals(output, utf8_tor) 58 59 # FIXME: We should only have one run* method to test 60 output = executive.run_and_throw_if_fail(["echo", "-n", unicode_tor], quiet=True) 61 self.assertEquals(output, unicode_tor) 62 63 output = executive.run_and_throw_if_fail(["echo", "-n", unicode_tor], quiet=True, decode_output=False) 64 self.assertEquals(output, utf8_tor) 41 if __name__ == '__main__': 42 unittest.main() -
trunk/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/dump_render_tree_thread.py
r58014 r58023 36 36 """ 37 37 38 from __future__ import with_statement39 40 import codecs41 38 import copy 42 39 import logging … … 93 90 filename = os.path.splitext(filename)[0] + "-stack.txt" 94 91 port.maybe_make_directory(os.path.split(filename)[0]) 95 with codecs.open(filename, "wb", "utf-8") as file: 96 file.write(error) 92 open(filename, "wb").write(error) # FIXME: This leaks a file handle. 97 93 elif error: 98 94 _log.debug("Previous test output extra lines after dump:\n%s" % … … 295 291 tests_run_filename = os.path.join(self._options.results_directory, 296 292 "tests_run.txt") 297 tests_run_file = codecs.open(tests_run_filename, "a", "utf-8")293 tests_run_file = open(tests_run_filename, "a") 298 294 299 295 while True: -
trunk/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/json_results_generator.py
r58014 r58023 28 28 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 29 30 from __future__ import with_statement31 32 import codecs33 30 import logging 34 31 import os … … 122 119 json = self._get_json() 123 120 if json: 124 results_file = codecs.open(self._results_file_path, "w", "utf-8")121 results_file = open(self._results_file_path, "w") 125 122 results_file.write(json) 126 123 results_file.close() … … 155 152 156 153 if os.path.exists(self._results_file_path): 157 with codecs.open(self._results_file_path, "r", "utf-8") as file:158 old_results =file.read()154 old_results_file = open(self._results_file_path, "r") 155 old_results = old_results_file.read() 159 156 elif self._builder_base_url: 160 157 # Check if we have the archived JSON file on the buildbot server. -
trunk/WebKitTools/Scripts/webkitpy/layout_tests/port/apache_http_server.py
r58014 r58023 30 30 """A class to start/stop the apache http server used by layout tests.""" 31 31 32 33 from __future__ import with_statement34 35 import codecs36 32 import logging 37 33 import optparse … … 156 152 httpd_config = self._port_obj._path_to_apache_config_file() 157 153 httpd_config_copy = os.path.join(output_dir, "httpd.conf") 158 # httpd.conf is always utf-8 according to http://archive.apache.org/gnats/10125 159 with codecs.open(httpd_config, "r", "utf-8") as httpd_config_file: 160 httpd_conf = httpd_config_file.read() 154 httpd_conf = open(httpd_config).read() 161 155 if self._is_cygwin(): 162 156 # This is a gross hack, but it lets us use the upstream .conf file … … 171 165 'ServerRoot "%s"' % self._get_cygwin_path(cygusr)) 172 166 173 with codecs.open(httpd_config_copy, "w", "utf-8") as file: 174 file.write(httpd_conf) 167 f = open(httpd_config_copy, 'wb') 168 f.write(httpd_conf) 169 f.close() 175 170 176 171 if self._is_cygwin(): -
trunk/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium.py
r58014 r58023 390 390 _log.warning('stopping test driver timed out, ' 391 391 'killing it') 392 # FIXME: This should use Executive. 393 null = open(os.devnull, "w") # Does this need an encoding? 392 null = open(os.devnull, "w") 394 393 subprocess.Popen(["kill", "-9", 395 394 str(self._proc.pid)], stderr=null) -
trunk/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium_linux.py
r58014 r58023 127 127 128 128 def _kill_all_process(self, process_name): 129 # FIXME: This should use Executive.130 129 null = open(os.devnull) 131 130 subprocess.call(['killall', '-TERM', '-u', os.getenv('USER'), -
trunk/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium_mac.py
r58014 r58023 100 100 101 101 def _check_wdiff_install(self): 102 # FIXME: This should use Executive.103 102 f = open(os.devnull, 'w') 104 103 rcode = 0 … … 118 117 def _kill_all_process(self, process_name): 119 118 """Kill any processes running under this name.""" 120 # FIXME: This should use Executive.121 119 # On Mac OS X 10.6, killall has a new constraint: -SIGNALNAME or 122 120 # -SIGNALNUMBER must come first. Example problem: -
trunk/WebKitTools/Scripts/webkitpy/layout_tests/port/gtk.py
r58014 r58023 63 63 64 64 def _kill_all_process(self, process_name): 65 # FIXME: This should use Executive.66 65 null = open(os.devnull) 67 66 subprocess.call(['killall', '-TERM', '-u', os.getenv('USER'), -
trunk/WebKitTools/Scripts/webkitpy/layout_tests/port/mac.py
r58014 r58023 134 134 # FIXME: This doesn't have anything to do with WebKit. 135 135 def _kill_all_process(self, process_name): 136 # FIXME: This should use Executive.137 136 # On Mac OS X 10.6, killall has a new constraint: -SIGNALNAME or 138 137 # -SIGNALNUMBER must come first. Example problem: -
trunk/WebKitTools/Scripts/webkitpy/layout_tests/port/mac_unittest.py
r58014 r58023 41 41 self.assertEqual(relative_paths, ['LayoutTests/platform/mac-leopard/Skipped', 'LayoutTests/platform/mac/Skipped']) 42 42 43 example_skipped_file = u"""43 example_skipped_file = """ 44 44 # <rdar://problem/5647952> fast/events/mouseout-on-window.html needs mac DRT to issue mouse out events 45 45 fast/events/mouseout-on-window.html -
trunk/WebKitTools/Scripts/webkitpy/layout_tests/port/qt.py
r58014 r58023 64 64 65 65 def _kill_all_process(self, process_name): 66 # FIXME: This should use Executive.67 66 null = open(os.devnull) 68 67 subprocess.call(['killall', '-TERM', '-u', os.getenv('USER'), -
trunk/WebKitTools/Scripts/webkitpy/layout_tests/port/server_process.py
r58014 r58023 216 216 _log.warning('stopping %s timed out, killing it' % 217 217 self._name) 218 # FIXME: This should use Executive.219 218 null = open(os.devnull, "w") 220 219 subprocess.Popen(["kill", "-9", -
trunk/WebKitTools/Scripts/webkitpy/layout_tests/port/webkit.py
r58014 r58023 30 30 """WebKit implementations of the Port interface.""" 31 31 32 33 from __future__ import with_statement34 35 import codecs36 32 import logging 37 33 import os … … 139 135 140 136 actual_length = os.stat(actual_filename).st_size 141 with open(actual_filename) as file: 142 actual_file = file.read() 137 actual_file = open(actual_filename).read() 143 138 expected_length = os.stat(expected_filename).st_size 144 with open(expected_filename) as file: 145 expected_file = file.read() 139 expected_file = open(expected_filename).read() 146 140 sp.write('Content-Length: %d\n%sContent-Length: %d\n%s' % 147 141 (actual_length, actual_file, expected_length, expected_file)) … … 172 166 result = False 173 167 elif output and diff_filename: 174 with open(diff_filename, 'w') as file: 175 file.write(output) 168 open(diff_filename, 'w').write(output) # FIXME: This leaks a file handle. 176 169 elif sp.timed_out: 177 170 _log.error("ImageDiff timed out on %s" % expected_filename) -
trunk/WebKitTools/Scripts/webkitpy/layout_tests/port/websocket_server.py
r58014 r58023 31 31 32 32 33 from __future__ import with_statement34 35 import codecs36 33 import logging 37 34 import optparse … … 155 152 156 153 output_log = os.path.join(self._output_dir, log_file_name + "-out.txt") 157 self._wsout = codecs.open(output_log, "w", "utf-8")154 self._wsout = open(output_log, "w") 158 155 159 156 python_interp = sys.executable … … 220 217 url = url + '://127.0.0.1:%d/' % self._port 221 218 if not url_is_alive(url): 222 fp = codecs.open(output_log, "utf-8")219 fp = open(output_log) 223 220 try: 224 221 for line in fp: … … 235 232 'Failed to start %s server.' % self._server_name) 236 233 if self._pidfile: 237 with codecs.open(self._pidfile, "w", "ascii") as file: 238 file.write("%d" % self._process.pid) 234 f = open(self._pidfile, 'w') 235 f.write("%d" % self._process.pid) 236 f.close() 239 237 240 238 def stop(self, force=False): … … 246 244 pid = self._process.pid 247 245 elif self._pidfile: 248 with codecs.open(self._pidfile, "r", "ascii") as file: 249 pid = int(f.read().strip()) 246 f = open(self._pidfile) 247 pid = int(f.read().strip()) 248 f.close() 250 249 251 250 if not pid: -
trunk/WebKitTools/Scripts/webkitpy/layout_tests/rebaseline_chromium_webkit_tests.py
r58014 r58023 42 42 """ 43 43 44 from __future__ import with_statement45 46 import codecs47 44 import copy 48 45 import logging … … 602 599 _log.info('Saving original file to "%s"', backup_file) 603 600 os.rename(path, backup_file) 604 # FIXME: What encoding are these files? 605 # Or is new_expectations always a byte array? 606 with open(path, "w") as file: 607 file.write(new_expectations) 601 f = open(path, "w") 602 f.write(new_expectations) 603 f.close() 608 604 else: 609 605 _log.info('No test was rebaselined so nothing to remove.') … … 720 716 baseline_filename, self._platform, 721 717 'old') 722 # FIXME: This assumes run_shell returns a byte array. 723 # We should be using an explicit encoding here. 724 with open(base_file, "wb") as file: 725 file.write(output) 718 f = open(base_file, 'wb') 719 f.write(output) 720 f.close() 726 721 _log.info(' Html: created old baseline file: "%s".', 727 722 base_file) … … 754 749 self._options.html_directory, baseline_filename, 755 750 self._platform, 'diff') 756 # FIXME: This assumes run_shell returns a byte array, not unicode()757 with open(diff_file, 'wb') as file:758 file.write(output)751 f = open(diff_file, 'wb') 752 f.write(output) 753 f.close() 759 754 _log.info(' Html: created baseline diff file: "%s".', 760 755 diff_file) … … 841 836 _log.debug(html) 842 837 843 with codecs.open(self._html_file, "w", "utf-8") as file: 844 file.write(html) 838 f = open(self._html_file, 'w') 839 f.write(html) 840 f.close() 845 841 846 842 _log.info('Baseline comparison html generated at "%s"', -
trunk/WebKitTools/Scripts/webkitpy/layout_tests/run_webkit_tests.py
r58014 r58023 368 368 tests_run_filename = os.path.join(self._options.results_directory, 369 369 "tests_run.txt") 370 with codecs.open(tests_run_filename, "w", "utf-8") as file: 371 file.write(tests_run_msg + "\n") 370 tests_run_file = open(tests_run_filename, "w") 371 tests_run_file.write(tests_run_msg + "\n") 372 tests_run_file.close() 372 373 373 374 len_skip_chunk = int(len(files) * len(skipped) / … … 966 967 dashboard). 967 968 """ 968 results_directory = self._options.results_directory 969 _log.debug("Writing JSON files in %s." % results_directory) 970 unexpected_json_path = os.path.join(results_directory, "unexpected_results.json") 971 with codecs.open(unexpected_json_path, "w", "utf-8") as file: 972 simplejson.dump(unexpected_results, file, sort_keys=True, indent=2) 969 _log.debug("Writing JSON files in %s." % 970 self._options.results_directory) 971 unexpected_file = open(os.path.join(self._options.results_directory, 972 "unexpected_results.json"), "w") 973 unexpected_file.write(simplejson.dumps(unexpected_results, 974 sort_keys=True, indent=2)) 975 unexpected_file.close() 973 976 974 977 # Write a json file of the test_expectations.txt file for the layout 975 978 # tests dashboard. 976 expectations_path = os.path.join(results_directory, "expectations.json") 979 expectations_file = open(os.path.join(self._options.results_directory, 980 "expectations.json"), "w") 977 981 expectations_json = \ 978 982 self._expectations.get_expectations_json_for_all_platforms() 979 with codecs.open(expectations_path, "w", "utf-8") as file:980 file.write(u"ADD_EXPECTATIONS(%s);" % expectations_json)983 expectations_file.write("ADD_EXPECTATIONS(" + expectations_json + ");") 984 expectations_file.close() 981 985 982 986 json_layout_results_generator.JSONLayoutResultsGenerator( … … 1389 1393 out_filename = os.path.join(self._options.results_directory, 1390 1394 "results.html") 1391 # FIXME: This should be re-written to prepare the string first 1392 # so that the "open" call can be wrapped in a with statement. 1393 out_file = codecs.open(out_filename, "w", "utf-8") 1395 out_file = open(out_filename, 'w') 1394 1396 # header 1395 1397 if self._options.full_results_html: … … 1404 1406 for test_file in test_files: 1405 1407 test_failures = result_summary.failures.get(test_file, []) 1406 out_file.write( u"<p><a href='%s'>%s</a><br />\n"1408 out_file.write("<p><a href='%s'>%s</a><br />\n" 1407 1409 % (self._port.filename_to_uri(test_file), 1408 1410 self._port.relative_test_filename(test_file))) 1409 1411 for failure in test_failures: 1410 out_file.write( u" %s<br/>"1412 out_file.write(" %s<br/>" 1411 1413 % failure.result_html_output( 1412 1414 self._port.relative_test_filename(test_file))) … … 1415 1417 # footer 1416 1418 out_file.write("</body></html>\n") 1417 out_file.close()1418 1419 return True 1419 1420 … … 1432 1433 tests = [] 1433 1434 for file in files: 1434 # FIXME: This could be cleaner using a list comprehension. 1435 for line in codecs.open(file, "r", "utf-8"): 1435 for line in open(file): 1436 1436 line = test_expectations.strip_comments(line) 1437 1437 if line: -
trunk/WebKitTools/Scripts/webkitpy/layout_tests/test_types/image_diff.py
r58014 r58023 35 35 """ 36 36 37 from __future__ import with_statement38 39 import codecs40 37 import errno 41 38 import logging … … 82 79 checksum: value of the actual checksum result 83 80 """ 84 with open(png_path, "rb") as png_file: 85 png_data = png_file.read() 81 png_file = open(png_path, "rb") 82 png_data = png_file.read() 83 png_file.close() 86 84 self._save_baseline_data(filename, png_data, ".png") 87 85 self._save_baseline_data(filename, checksum, ".checksum") … … 143 141 _log.debug('Using %s' % expected_png_file) 144 142 145 # FIXME: We repeat this pattern often, we should share code.146 143 try: 147 with codecs.open(expected_hash_file, "r", "ascii") as file: 148 expected_hash = file.read() 144 expected_hash = open(expected_hash_file, "r").read() 149 145 except IOError, e: 150 146 if errno.ENOENT != e.errno: -
trunk/WebKitTools/Scripts/webkitpy/layout_tests/test_types/test_type_base.py
r58020 r58023 33 33 """ 34 34 35 from __future__ import with_statement36 37 import codecs38 35 import cgi 39 36 import errno … … 154 151 raise NotImplemented 155 152 156 def _write_into_file_at_path(self, file_path, contents, encoding=None): 157 """Writes contents at file_path, using encoding.""" 158 if not encoding: 159 # FIXME: This is a hack to handle binary data. I thought 160 # encoding=None worked, but I guess not. 161 with open(file_path, "wb") as file: 162 file.write(contents) 163 return 164 with codecs.open(file_path, "w", encoding=encoding) as file: 165 file.write(contents) 153 def _write_into_file_at_path(self, file_path, contents): 154 file = open(file_path, "wb") 155 file.write(contents) 156 file.close() 166 157 167 158 def write_output_files(self, port, filename, file_type, … … 185 176 actual_filename = self.output_filename(filename, self.FILENAME_SUFFIX_ACTUAL + file_type) 186 177 expected_filename = self.output_filename(filename, self.FILENAME_SUFFIX_EXPECTED + file_type) 187 # FIXME: The fact that this function can take many different188 # types of data is a total hack.189 encoding = "utf-8" if print_text_diffs else None190 178 if output: 191 self._write_into_file_at_path(actual_filename, output , encoding)179 self._write_into_file_at_path(actual_filename, output) 192 180 if expected: 193 self._write_into_file_at_path(expected_filename, expected , encoding)181 self._write_into_file_at_path(expected_filename, expected) 194 182 195 183 if not output or not expected: … … 201 189 diff = port.diff_text(expected, output, expected_filename, actual_filename) 202 190 diff_filename = self.output_filename(filename, self.FILENAME_SUFFIX_DIFF + file_type) 203 self._write_into_file_at_path(diff_filename, diff , encoding="utf-8")191 self._write_into_file_at_path(diff_filename, diff) 204 192 205 193 # Shell out to wdiff to get colored inline diffs. 206 194 wdiff = port.wdiff_text(expected_filename, actual_filename) 207 195 wdiff_filename = self.output_filename(filename, self.FILENAME_SUFFIX_WDIFF) 208 self._write_into_file_at_path(wdiff_filename, wdiff , encoding="utf-8")196 self._write_into_file_at_path(wdiff_filename, wdiff) 209 197 210 198 # Use WebKit's PrettyPatch.rb to get an HTML diff. 211 199 pretty_patch = port.pretty_patch_text(diff_filename) 212 200 pretty_patch_filename = self.output_filename(filename, self.FILENAME_SUFFIX_PRETTY_PATCH) 213 self._write_into_file_at_path(pretty_patch_filename, pretty_patch , encoding="utf-8")201 self._write_into_file_at_path(pretty_patch_filename, pretty_patch) -
trunk/WebKitTools/Scripts/webkitpy/layout_tests/test_types/text_diff.py
r58014 r58023 34 34 """ 35 35 36 from __future__ import with_statement37 38 import codecs39 36 import errno 40 37 import logging … … 74 71 75 72 def get_normalized_text(self, filename): 76 # FIXME: We repeat this pattern often, we should share code.77 73 try: 78 with codecs.open(filename, "r", "utf-8") as file: 79 text = file.read() 74 text = open(filename).read() 80 75 except IOError, e: 81 76 if errno.ENOENT != e.errno: -
trunk/WebKitTools/Scripts/webkitpy/style/filereader_unittest.py
r58014 r58023 23 23 """Contains unit tests for filereader.py.""" 24 24 25 from __future__ import with_statement26 27 import codecs28 25 import os 29 26 import shutil … … 71 68 shutil.rmtree(self._temp_dir) 72 69 73 def _create_file(self, rel_path, text , encoding="utf-8"):70 def _create_file(self, rel_path, text): 74 71 """Create a file with given text and return the path to the file.""" 75 # FIXME: There are better/more secure APIs for creatin tmp file paths.76 72 file_path = os.path.join(self._temp_dir, rel_path) 77 with codecs.open(file_path, "w", encoding) as file: 78 file.write(text) 73 74 file = open(file_path, 'w') 75 file.write(text) 76 file.close() 77 79 78 return file_path 80 79 -
trunk/WebKitTools/Scripts/webkitpy/thirdparty/__init__.py
r58014 r58023 25 25 """Autoinstalls third-party code required by WebKit.""" 26 26 27 from __future__ import with_statement28 29 import codecs30 27 import os 31 28 … … 92 89 readme_path = os.path.join(autoinstalled_dir, "README") 93 90 if not os.path.exists(readme_path): 94 with codecs.open(readme_path, "w", "ascii") as file: 91 file = open(readme_path, "w") 92 try: 95 93 file.write("This directory is auto-generated by WebKit and is " 96 94 "safe to delete.\nIt contains needed third-party Python " 97 95 "packages automatically downloaded from the web.") 96 finally: 97 file.close() -
trunk/WebKitTools/Scripts/webkitpy/tool/commands/earlywarningsystem.py
r58014 r58023 26 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 29 from StringIO import StringIO 28 30 29 31 from webkitpy.tool.commands.queues import AbstractReviewQueue -
trunk/WebKitTools/Scripts/webkitpy/tool/commands/queues.py
r58014 r58023 72 72 webkit_patch_args = [self.tool.path()] 73 73 # FIXME: This is a hack, we should have a more general way to pass global options. 74 # FIXME: We must always pass global options and their value in one argument75 # because our global option code looks for the first argument which does76 # not begin with "-" and assumes that is the command name.77 74 webkit_patch_args += ["--status-host=%s" % self.tool.status_server.host] 78 webkit_patch_args .extend(args)75 webkit_patch_args += map(str, args) 79 76 return self.tool.executive.run_and_throw_if_fail(webkit_patch_args) 80 77 … … 127 124 message = "Error: %s" % message 128 125 output = script_error.message_with_output(output_limit=1024*1024) # 1MB 129 # We pre-encode the string to a byte array before passing it 130 # to status_server, because ClientForm (part of mechanize) 131 # wants a file-like object with pre-encoded data. 132 return tool.status_server.update_status(cls.name, message, state["patch"], StringIO(output.encode("utf-8"))) 126 return tool.status_server.update_status(cls.name, message, state["patch"], StringIO(output)) 133 127 134 128 -
trunk/WebKitTools/Scripts/webkitpy/tool/commands/queues_unittest.py
r58014 r58023 76 76 77 77 queue.run_webkit_patch(run_args) 78 expected_run_args = ["echo", "--status-host=example.com"] + run_args78 expected_run_args = ["echo", "--status-host=example.com"] + map(str, run_args) 79 79 tool.executive.run_and_throw_if_fail.assert_called_with(expected_run_args) 80 80 … … 151 151 1 patch in commit-queue [106] 152 152 """, 153 "process_work_item": "MOCK run_and_throw_if_fail: ['echo', '--status-host=example.com', 'land-attachment', '--force-clean', '--build', '--test', '--non-interactive', '--ignore-builders', '--build-style=both', '--quiet', 76543]\n",153 "process_work_item": "MOCK run_and_throw_if_fail: ['echo', '--status-host=example.com', 'land-attachment', '--force-clean', '--build', '--test', '--non-interactive', '--ignore-builders', '--build-style=both', '--quiet', '76543']\n", 154 154 } 155 155 self.assert_queue_outputs(CommitQueue(), tool=tool, work_item=rollout_patch, expected_stderr=expected_stderr) -
trunk/WebKitTools/Scripts/webkitpy/tool/commands/upload.py
r58014 r58023 31 31 import os 32 32 import re 33 import StringIO 33 34 import sys 34 35 … … 260 261 return comment_text 261 262 263 def _diff_file_for_commit(self, tool, commit_id): 264 diff = tool.scm().create_patch_from_local_commit(commit_id) 265 return StringIO.StringIO(diff) # add_patch_to_bug expects a file-like object 266 262 267 def execute(self, options, args, tool): 263 268 commit_ids = tool.scm().commit_ids_from_commitish_arguments(args) … … 280 285 have_obsoleted_patches.add(bug_id) 281 286 282 diff = tool.scm().create_patch_from_local_commit(commit_id)287 diff_file = self._diff_file_for_commit(tool, commit_id) 283 288 description = options.description or commit_message.description(lstrip=True, strip_url=True) 284 289 comment_text = self._comment_text_for_commit(options, commit_message, tool, commit_id) 285 tool.bugs.add_patch_to_bug(bug_id, diff , description, comment_text, mark_for_review=options.review, mark_for_commit_queue=options.request_commit)290 tool.bugs.add_patch_to_bug(bug_id, diff_file, description, comment_text, mark_for_review=options.review, mark_for_commit_queue=options.request_commit) 286 291 287 292 … … 400 405 401 406 diff = tool.scm().create_patch_from_local_commit(commit_id) 402 bug_id = tool.bugs.create_bug(bug_title, comment_text, options.component, diff, "Patch", cc=options.cc, mark_for_review=options.review, mark_for_commit_queue=options.request_commit) 407 diff_file = StringIO.StringIO(diff) # create_bug expects a file-like object 408 bug_id = tool.bugs.create_bug(bug_title, comment_text, options.component, diff_file, "Patch", cc=options.cc, mark_for_review=options.review, mark_for_commit_queue=options.request_commit) 403 409 404 410 if bug_id and len(commit_ids) > 1: … … 419 425 420 426 diff = tool.scm().create_patch() 421 bug_id = tool.bugs.create_bug(bug_title, comment_text, options.component, diff, "Patch", cc=options.cc, mark_for_review=options.review, mark_for_commit_queue=options.request_commit) 427 diff_file = StringIO.StringIO(diff) # create_bug expects a file-like object 428 bug_id = tool.bugs.create_bug(bug_title, comment_text, options.component, diff_file, "Patch", cc=options.cc, mark_for_review=options.review, mark_for_commit_queue=options.request_commit) 422 429 423 430 def prompt_for_bug_title_and_comment(self): -
trunk/WebKitTools/Scripts/webkitpy/tool/mocktool.py
r58014 r58023 261 261 bug_description, 262 262 component=None, 263 diff=None,263 patch_file_object=None, 264 264 patch_description=None, 265 265 cc=None, … … 303 303 def add_patch_to_bug(self, 304 304 bug_id, 305 diff,305 patch_file_object, 306 306 description, 307 307 comment_text=None, -
trunk/WebKitTools/Scripts/webkitpy/tool/steps/abstractstep.py
r58014 r58023 40 40 log("Running %s" % script_name) 41 41 # FIXME: This should use self.port() 42 self._tool.executive.run_and_throw_if_fail( [port.script_path(script_name)], quiet)42 self._tool.executive.run_and_throw_if_fail(port.script_path(script_name), quiet) 43 43 44 44 # FIXME: The port should live on the tool. -
trunk/WebKitTools/Scripts/webkitpy/tool/steps/postdiff.py
r58014 r58023 27 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 28 29 import StringIO 30 29 31 from webkitpy.tool.steps.abstractstep import AbstractStep 30 32 from webkitpy.tool.steps.options import Options … … 43 45 def run(self, state): 44 46 diff = self.cached_lookup(state, "diff") 47 diff_file = StringIO.StringIO(diff) # add_patch_to_bug expects a file-like object 45 48 description = self._options.description or "Patch" 46 49 comment_text = None … … 50 53 if codereview_issue: 51 54 description += "-%s" % state["codereview_issue"] 52 self._tool.bugs.add_patch_to_bug(state["bug_id"], diff , description, comment_text=comment_text, mark_for_review=self._options.review, mark_for_commit_queue=self._options.request_commit)55 self._tool.bugs.add_patch_to_bug(state["bug_id"], diff_file, description, comment_text=comment_text, mark_for_review=self._options.review, mark_for_commit_queue=self._options.request_commit) 53 56 if self._options.open_bug: 54 57 self._tool.user.open_url(self._tool.bugs.bug_url_for_bug_id(state["bug_id"])) -
trunk/WebKitTools/Scripts/webkitpy/tool/steps/postdiffforcommit.py
r58014 r58023 27 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 28 29 import StringIO 30 29 31 from webkitpy.tool.steps.abstractstep import AbstractStep 30 32 … … 34 36 self._tool.bugs.add_patch_to_bug( 35 37 state["bug_id"], 36 self.cached_lookup(state, "diff"),38 StringIO.StringIO(self.cached_lookup(state, "diff")), 37 39 "Patch for landing", 38 40 mark_for_review=False, -
trunk/WebKitTools/Scripts/webkitpy/tool/steps/postdiffforrevert.py
r58014 r58023 27 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 28 29 import StringIO 30 29 31 from webkitpy.common.net.bugzilla import Attachment 30 32 from webkitpy.tool.steps.abstractstep import AbstractStep … … 43 45 self._tool.bugs.add_patch_to_bug( 44 46 state["bug_id"], 45 self.cached_lookup(state, "diff"),47 StringIO.StringIO(self.cached_lookup(state, "diff")), 46 48 "%s%s" % (Attachment.rollout_preamble, state["revision"]), 47 49 comment_text=comment_text, -
trunk/WebKitTools/Scripts/webkitpy/tool/steps/steps_unittest.py
r58014 r58023 49 49 options = Mock() 50 50 options.update = True 51 expected_stderr = "Updating working directory\n" 52 OutputCapture().assert_outputs(self, self._run_step, [Update, options], expected_stderr=expected_stderr) 51 self._run_step(Update, options) 53 52 54 53 def test_prompt_for_bug_or_title_step(self):
Note: See TracChangeset
for help on using the changeset viewer.