Title: [267023] trunk/Tools
Revision
267023
Author
[email protected]
Date
2020-09-14 10:58:51 -0700 (Mon, 14 Sep 2020)

Log Message

[webkitcorepy] Log autoinstall details even without a logger configured
https://bugs.webkit.org/show_bug.cgi?id=216480

Reviewed by Dewei Zhu.

* Scripts/libraries/webkitcorepy/webkitcorepy/__init__.py: Bump version.
* Scripts/libraries/webkitcorepy/webkitcorepy/autoinstall.py:
(Package.install): Use AutoInstall.log instead of logging.
(AutoInstall):
(AutoInstall.log): Check log to see if a logger is configured, if one is not,
output the message to stderr instead.

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (267022 => 267023)


--- trunk/Tools/ChangeLog	2020-09-14 17:47:34 UTC (rev 267022)
+++ trunk/Tools/ChangeLog	2020-09-14 17:58:51 UTC (rev 267023)
@@ -1,3 +1,17 @@
+2020-09-14  Jonathan Bedard  <[email protected]>
+
+        [webkitcorepy] Log autoinstall details even without a logger configured
+        https://bugs.webkit.org/show_bug.cgi?id=216480
+
+        Reviewed by Dewei Zhu.
+
+        * Scripts/libraries/webkitcorepy/webkitcorepy/__init__.py: Bump version.
+        * Scripts/libraries/webkitcorepy/webkitcorepy/autoinstall.py:
+        (Package.install): Use AutoInstall.log instead of logging.
+        (AutoInstall):
+        (AutoInstall.log): Check log to see if a logger is configured, if one is not,
+        output the message to stderr instead.
+
 2020-09-14  Aakash Jain  <[email protected]>
 
         [EWS] Layout testers can go in an infinite RETRY loop when there are 30+ failures on trunk

Modified: trunk/Tools/Scripts/libraries/webkitcorepy/webkitcorepy/__init__.py (267022 => 267023)


--- trunk/Tools/Scripts/libraries/webkitcorepy/webkitcorepy/__init__.py	2020-09-14 17:47:34 UTC (rev 267022)
+++ trunk/Tools/Scripts/libraries/webkitcorepy/webkitcorepy/__init__.py	2020-09-14 17:58:51 UTC (rev 267023)
@@ -35,7 +35,7 @@
 from webkitcorepy.subprocess_utils import TimeoutExpired, CompletedProcess, run
 from webkitcorepy.output_capture import LoggerCapture, OutputCapture, OutputDuplicate
 
-version = Version(0, 4, 8)
+version = Version(0, 4, 9)
 
 from webkitcorepy.autoinstall import Package, AutoInstall
 if sys.version_info > (3, 0):

Modified: trunk/Tools/Scripts/libraries/webkitcorepy/webkitcorepy/autoinstall.py (267022 => 267023)


--- trunk/Tools/Scripts/libraries/webkitcorepy/webkitcorepy/autoinstall.py	2020-09-14 17:47:34 UTC (rev 267022)
+++ trunk/Tools/Scripts/libraries/webkitcorepy/webkitcorepy/autoinstall.py	2020-09-14 17:58:51 UTC (rev 267023)
@@ -21,6 +21,7 @@
 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 import json
+import logging
 import math
 import os
 import platform
@@ -32,6 +33,7 @@
 import tempfile
 import zipfile
 
+from logging import NullHandler
 from webkitcorepy import log
 from webkitcorepy.version import Version
 from xml.dom import minidom
@@ -215,7 +217,7 @@
             install_location = os.path.dirname(self.location)
             shutil.rmtree(self.location, ignore_errors=True)
 
-            log.warning('Downloading {}...'.format(archive))
+            AutoInstall.log('Downloading {}...'.format(archive))
             archive.download()
 
             temp_location = os.path.join(tempfile.gettempdir(), self.name)
@@ -230,10 +232,10 @@
                 if not os.path.exists(os.path.join(candidate, 'setup.py')):
                     continue
 
-                log.warning('Installing {}...'.format(archive))
+                AutoInstall.log('Installing {}...'.format(archive))
 
                 if self.slow_install:
-                    log.warning('{} is known to be slow to install'.format(archive))
+                    AutoInstall.log('{} is known to be slow to install'.format(archive))
 
                 with open(os.devnull, 'w') as devnull:
                     subprocess.check_call(
@@ -290,9 +292,9 @@
                 json.dump(AutoInstall.manifest, file, indent=4)
             AutoInstall.userspace_should_own(manifest)
 
-            log.warning('Installed {}!'.format(archive))
+            AutoInstall.log('Installed {}!'.format(archive))
         except Exception:
-            log.critical('Failed to install {}!'.format(archive))
+            AutoInstall.log('Failed to install {}!'.format(archive), level=logging.CRITICAL)
             raise
 
 
@@ -491,5 +493,12 @@
                         pass
                     yield tags.Tag(tag.interpreter, tag.abi, override)
 
+    @classmethod
+    def log(cls, message, level=logging.WARNING):
+        if not log.handlers or all([isinstance(handle, NullHandler) for handle in log.handlers]):
+            sys.stderr.write(message + '\n')
+        else:
+            log.log(level, message)
 
+
 sys.meta_path.insert(0, AutoInstall)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to