Title: [136221] trunk/Tools
Revision
136221
Author
[email protected]
Date
2012-11-30 02:56:16 -0800 (Fri, 30 Nov 2012)

Log Message

Finally remove webkitpy.common.system.deprecated_logging
https://bugs.webkit.org/show_bug.cgi?id=103624

Reviewed by Adam Barth.

Remove the deprecated logging module and its unit tests now that such logging is not
used anymore in webkitpy.

The tee and OutputTee classes are moved into a new module, webkitpy.common.system.outputtee.
The tee class is renamed to Tee to conform with the usual guidelines.

Only unit test for the Tee class is currently provided as the OutputTee is not currently
using the webkitpy Filesystem abstraction that would make its functionality testable.

* Scripts/webkitpy/common/system/executive.py: tee (now Tee) is now in a new module.
(Executive.run_and_throw_if_fail):
* Scripts/webkitpy/common/system/outputtee.py: Renamed from Tools/Scripts/webkitpy/common/system/deprecated_logging.py.
(Tee):
(Tee.__init__):
(Tee.write):
(OutputTee):
(OutputTee.__init__):
(OutputTee.add_log):
(OutputTee.remove_log):
(OutputTee._open_log_file):
(OutputTee._tee_outputs_to_files):
* Scripts/webkitpy/common/system/outputtee_unittest.py: Renamed from Tools/Scripts/webkitpy/common/system/deprecated_logging_unittest.py.
(SimpleTeeTest):
(SimpleTeeTest.test_simple_tee):
* Scripts/webkitpy/tool/bot/queueengine.py: OutputTee is now in a new module.
* Scripts/webkitpy/webkitpy.pyproj: Remove the deprecated_logging module and related unit test file.

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/Tools/ChangeLog (136220 => 136221)


--- trunk/Tools/ChangeLog	2012-11-30 10:52:25 UTC (rev 136220)
+++ trunk/Tools/ChangeLog	2012-11-30 10:56:16 UTC (rev 136221)
@@ -1,3 +1,37 @@
+2012-11-30  Zan Dobersek  <[email protected]>
+
+        Finally remove webkitpy.common.system.deprecated_logging
+        https://bugs.webkit.org/show_bug.cgi?id=103624
+
+        Reviewed by Adam Barth.
+
+        Remove the deprecated logging module and its unit tests now that such logging is not
+        used anymore in webkitpy.
+
+        The tee and OutputTee classes are moved into a new module, webkitpy.common.system.outputtee.
+        The tee class is renamed to Tee to conform with the usual guidelines.
+
+        Only unit test for the Tee class is currently provided as the OutputTee is not currently
+        using the webkitpy Filesystem abstraction that would make its functionality testable.
+
+        * Scripts/webkitpy/common/system/executive.py: tee (now Tee) is now in a new module.
+        (Executive.run_and_throw_if_fail):
+        * Scripts/webkitpy/common/system/outputtee.py: Renamed from Tools/Scripts/webkitpy/common/system/deprecated_logging.py.
+        (Tee):
+        (Tee.__init__):
+        (Tee.write):
+        (OutputTee):
+        (OutputTee.__init__):
+        (OutputTee.add_log):
+        (OutputTee.remove_log):
+        (OutputTee._open_log_file):
+        (OutputTee._tee_outputs_to_files):
+        * Scripts/webkitpy/common/system/outputtee_unittest.py: Renamed from Tools/Scripts/webkitpy/common/system/deprecated_logging_unittest.py.
+        (SimpleTeeTest):
+        (SimpleTeeTest.test_simple_tee):
+        * Scripts/webkitpy/tool/bot/queueengine.py: OutputTee is now in a new module.
+        * Scripts/webkitpy/webkitpy.pyproj: Remove the deprecated_logging module and related unit test file.
+
 2012-11-30  Sudarsana Nagineni  <[email protected]>
 
         [EFL][WK2] Add support for PlatformWebView::simulateRightClick() in TestWebKitAPI

Deleted: trunk/Tools/Scripts/webkitpy/common/system/deprecated_logging.py (136220 => 136221)


--- trunk/Tools/Scripts/webkitpy/common/system/deprecated_logging.py	2012-11-30 10:52:25 UTC (rev 136220)
+++ trunk/Tools/Scripts/webkitpy/common/system/deprecated_logging.py	2012-11-30 10:56:16 UTC (rev 136221)
@@ -1,91 +0,0 @@
-# Copyright (c) 2009, Google Inc. All rights reserved.
-# Copyright (c) 2009 Apple Inc. All rights reserved.
-# 
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-# 
-#     * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-#     * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following disclaimer
-# in the documentation and/or other materials provided with the
-# distribution.
-#     * Neither the name of Google Inc. nor the names of its
-# contributors may be used to endorse or promote products derived from
-# this software without specific prior written permission.
-# 
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-# WebKit's Python module for logging
-# This module is now deprecated in favor of python's built-in logging.py.
-
-import codecs
-import os
-import sys
-
-
-def log(string):
-    print >> sys.stderr, string
-
-
-def error(string):
-    log("ERROR: %s" % string)
-    sys.exit(1)
-
-
-# Simple class to split output between multiple destinations
-class tee:
-    def __init__(self, *files):
-        self.files = files
-
-    # Callers should pass an already encoded string for writing.
-    def write(self, bytes):
-        for file in self.files:
-            file.write(bytes)
-
-
-class OutputTee:
-    def __init__(self):
-        self._original_stdout = None
-        self._original_stderr = None
-        self._files_for_output = []
-
-    def add_log(self, path):
-        log_file = self._open_log_file(path)
-        self._files_for_output.append(log_file)
-        self._tee_outputs_to_files(self._files_for_output)
-        return log_file
-
-    def remove_log(self, log_file):
-        self._files_for_output.remove(log_file)
-        self._tee_outputs_to_files(self._files_for_output)
-        log_file.close()
-
-    @staticmethod
-    def _open_log_file(log_path):
-        (log_directory, log_name) = os.path.split(log_path)
-        if log_directory and not os.path.exists(log_directory):
-            os.makedirs(log_directory)
-        return codecs.open(log_path, "a+", "utf-8")
-
-    def _tee_outputs_to_files(self, files):
-        if not self._original_stdout:
-            self._original_stdout = sys.stdout
-            self._original_stderr = sys.stderr
-        if files and len(files):
-            sys.stdout = tee(self._original_stdout, *files)
-            sys.stderr = tee(self._original_stderr, *files)
-        else:
-            sys.stdout = self._original_stdout
-            sys.stderr = self._original_stderr

Deleted: trunk/Tools/Scripts/webkitpy/common/system/deprecated_logging_unittest.py (136220 => 136221)


--- trunk/Tools/Scripts/webkitpy/common/system/deprecated_logging_unittest.py	2012-11-30 10:52:25 UTC (rev 136220)
+++ trunk/Tools/Scripts/webkitpy/common/system/deprecated_logging_unittest.py	2012-11-30 10:56:16 UTC (rev 136221)
@@ -1,60 +0,0 @@
-# Copyright (C) 2009 Google Inc. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-#
-#    * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-#    * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following disclaimer
-# in the documentation and/or other materials provided with the
-# distribution.
-#    * Neither the name of Google Inc. nor the names of its
-# contributors may be used to endorse or promote products derived from
-# this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-import os
-import StringIO
-import tempfile
-import unittest
-
-from webkitpy.common.system.executive import ScriptError
-from webkitpy.common.system.deprecated_logging import *
-
-class LoggingTest(unittest.TestCase):
-
-    def assert_log_equals(self, log_input, expected_output):
-        original_stderr = sys.stderr
-        test_stderr = StringIO.StringIO()
-        sys.stderr = test_stderr
-
-        try:
-            log(log_input)
-            actual_output = test_stderr.getvalue()
-        finally:
-            sys.stderr = original_stderr
-
-        self.assertEqual(actual_output, expected_output, "log(\"%s\") expected: %s actual: %s" % (log_input, expected_output, actual_output))
-
-    def test_log(self):
-        self.assert_log_equals("test", "test\n")
-
-        # Test that log() does not throw an exception when passed an object instead of a string.
-        self.assert_log_equals(ScriptError(message="ScriptError"), "ScriptError\n")
-
-
-if __name__ == '__main__':
-    unittest.main()

Modified: trunk/Tools/Scripts/webkitpy/common/system/executive.py (136220 => 136221)


--- trunk/Tools/Scripts/webkitpy/common/system/executive.py	2012-11-30 10:52:25 UTC (rev 136220)
+++ trunk/Tools/Scripts/webkitpy/common/system/executive.py	2012-11-30 10:56:16 UTC (rev 136221)
@@ -37,7 +37,7 @@
 import sys
 import time
 
-from webkitpy.common.system.deprecated_logging import tee
+from webkitpy.common.system.outputtee import Tee
 from webkitpy.common.system.filesystem import FileSystem
 
 
@@ -135,7 +135,7 @@
         if quiet:
             dev_null = open(os.devnull, "w")  # FIXME: Does this need an encoding?
             tee_stdout = dev_null
-        child_stdout = tee(child_out_file, tee_stdout)
+        child_stdout = Tee(child_out_file, tee_stdout)
         exit_code = self._run_command_with_teed_output(args, child_stdout, **kwargs)
         if quiet:
             dev_null.close()

Added: trunk/Tools/Scripts/webkitpy/common/system/outputtee.py (0 => 136221)


--- trunk/Tools/Scripts/webkitpy/common/system/outputtee.py	                        (rev 0)
+++ trunk/Tools/Scripts/webkitpy/common/system/outputtee.py	2012-11-30 10:56:16 UTC (rev 136221)
@@ -0,0 +1,79 @@
+# Copyright (c) 2009, Google Inc. All rights reserved.
+# Copyright (c) 2009 Apple Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+#     * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#     * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+#     * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+import codecs
+import os
+import sys
+
+
+# Simple class to split output between multiple destinations
+class Tee:
+    def __init__(self, *files):
+        self.files = files
+
+    # Callers should pass an already encoded string for writing.
+    def write(self, bytes):
+        for file in self.files:
+            file.write(bytes)
+
+
+class OutputTee:
+    def __init__(self):
+        self._original_stdout = None
+        self._original_stderr = None
+        self._files_for_output = []
+
+    def add_log(self, path):
+        log_file = self._open_log_file(path)
+        self._files_for_output.append(log_file)
+        self._tee_outputs_to_files(self._files_for_output)
+        return log_file
+
+    def remove_log(self, log_file):
+        self._files_for_output.remove(log_file)
+        self._tee_outputs_to_files(self._files_for_output)
+        log_file.close()
+
+    @staticmethod
+    def _open_log_file(log_path):
+        (log_directory, log_name) = os.path.split(log_path)
+        if log_directory and not os.path.exists(log_directory):
+            os.makedirs(log_directory)
+        return codecs.open(log_path, "a+", "utf-8")
+
+    def _tee_outputs_to_files(self, files):
+        if not self._original_stdout:
+            self._original_stdout = sys.stdout
+            self._original_stderr = sys.stderr
+        if files and len(files):
+            sys.stdout = Tee(self._original_stdout, *files)
+            sys.stderr = Tee(self._original_stderr, *files)
+        else:
+            sys.stdout = self._original_stdout
+            sys.stderr = self._original_stderr

Added: trunk/Tools/Scripts/webkitpy/common/system/outputtee_unittest.py (0 => 136221)


--- trunk/Tools/Scripts/webkitpy/common/system/outputtee_unittest.py	                        (rev 0)
+++ trunk/Tools/Scripts/webkitpy/common/system/outputtee_unittest.py	2012-11-30 10:56:16 UTC (rev 136221)
@@ -0,0 +1,43 @@
+# Copyright (C) 2012 Zan Dobersek <[email protected]>
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+#    * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#    * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+#    * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+import StringIO
+import unittest
+
+from webkitpy.common.system.outputtee import Tee, OutputTee
+
+
+class SimpleTeeTest(unittest.TestCase):
+    def test_simple_tee(self):
+        file1, file2 = StringIO.StringIO(), StringIO.StringIO()
+        tee = Tee(file1, file2)
+        tee.write("foo bar\n")
+        tee.write("baz\n")
+
+        self.assertEqual(file1.getvalue(), "foo bar\nbaz\n")
+        self.assertEqual(file2.getvalue(), file1.getvalue())

Modified: trunk/Tools/Scripts/webkitpy/tool/bot/queueengine.py (136220 => 136221)


--- trunk/Tools/Scripts/webkitpy/tool/bot/queueengine.py	2012-11-30 10:52:25 UTC (rev 136220)
+++ trunk/Tools/Scripts/webkitpy/tool/bot/queueengine.py	2012-11-30 10:56:16 UTC (rev 136221)
@@ -34,7 +34,7 @@
 from datetime import datetime, timedelta
 
 from webkitpy.common.system.executive import ScriptError
-from webkitpy.common.system.deprecated_logging import OutputTee
+from webkitpy.common.system.outputtee import OutputTee
 
 _log = logging.getLogger(__name__)
 

Modified: trunk/Tools/Scripts/webkitpy/webkitpy.pyproj (136220 => 136221)


--- trunk/Tools/Scripts/webkitpy/webkitpy.pyproj	2012-11-30 10:52:25 UTC (rev 136220)
+++ trunk/Tools/Scripts/webkitpy/webkitpy.pyproj	2012-11-30 10:56:16 UTC (rev 136221)
@@ -130,8 +130,6 @@
     <Compile Include="common\system\autoinstall.py" />
     <Compile Include="common\system\crashlogs.py" />
     <Compile Include="common\system\crashlogs_unittest.py" />
-    <Compile Include="common\system\deprecated_logging.py" />
-    <Compile Include="common\system\deprecated_logging_unittest.py" />
     <Compile Include="common\system\environment.py" />
     <Compile Include="common\system\environment_unittest.py" />
     <Compile Include="common\system\executive.py" />
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to