Title: [276374] trunk/Tools
Revision
276374
Author
gsnedd...@apple.com
Date
2021-04-21 10:58:46 -0700 (Wed, 21 Apr 2021)

Log Message

Handle os.getenv returning None
https://bugs.webkit.org/show_bug.cgi?id=224869

Reviewed by Jonathan Bedard.

* Scripts/webkitpy/common/checkout/scm/svn.py:
(SVNRepository.has_authorization_for_realm): This entirely replaces reading
$HOME with a call to os.path.expanduser. Notably, the stdlib function both
handles cases on Unix-like OSes when $HOME is undefined and on Windows (where
$HOME is undefined by default) correctly constructs the path.
* Scripts/webkitpy/common/system/executive.py:
(Executive.kill_all): Handle $USER being undefined by just attempting to kill
all processes regardless of owner.

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (276373 => 276374)


--- trunk/Tools/ChangeLog	2021-04-21 17:57:23 UTC (rev 276373)
+++ trunk/Tools/ChangeLog	2021-04-21 17:58:46 UTC (rev 276374)
@@ -1,3 +1,19 @@
+2021-04-21  Sam Sneddon  <gsnedd...@apple.com>
+
+        Handle os.getenv returning None
+        https://bugs.webkit.org/show_bug.cgi?id=224869
+
+        Reviewed by Jonathan Bedard.
+
+        * Scripts/webkitpy/common/checkout/scm/svn.py:
+        (SVNRepository.has_authorization_for_realm): This entirely replaces reading
+        $HOME with a call to os.path.expanduser. Notably, the stdlib function both
+        handles cases on Unix-like OSes when $HOME is undefined and on Windows (where
+        $HOME is undefined by default) correctly constructs the path.
+        * Scripts/webkitpy/common/system/executive.py:
+        (Executive.kill_all): Handle $USER being undefined by just attempting to kill
+        all processes regardless of owner.
+
 2021-04-21  Simon Fraser  <simon.fra...@apple.com>
 
         Enhance scrolling-related trace points

Modified: trunk/Tools/Scripts/webkitpy/common/checkout/scm/svn.py (276373 => 276374)


--- trunk/Tools/Scripts/webkitpy/common/checkout/scm/svn.py	2021-04-21 17:57:23 UTC (rev 276373)
+++ trunk/Tools/Scripts/webkitpy/common/checkout/scm/svn.py	2021-04-21 17:58:46 UTC (rev 276374)
@@ -53,10 +53,17 @@
     svn_server_host = svn_server_host
     svn_server_realm = svn_server_realm
 
-    def has_authorization_for_realm(self, realm, home_directory=os.getenv("HOME")):
+    def has_authorization_for_realm(self, realm, home_directory=None):
         # If we are working on a file:// repository realm will be None
         if realm is None:
             return True
+
+        # Find the user's home directory
+        if home_directory is None:
+            home_directory = os.path.expanduser("~")
+            if home_directory == "~":
+                return False
+
         # ignore false positives for methods implemented in the mixee class. pylint: disable=E1101
         # Assumes find and grep are installed.
         if not os.path.isdir(os.path.join(home_directory, ".subversion")):

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


--- trunk/Tools/Scripts/webkitpy/common/system/executive.py	2021-04-21 17:57:23 UTC (rev 276373)
+++ trunk/Tools/Scripts/webkitpy/common/system/executive.py	2021-04-21 17:58:46 UTC (rev 276374)
@@ -354,7 +354,10 @@
         # uses KILL.  Windows is always using /f (which seems like -KILL).
         # We should pick one mode, or add support for switching between them.
         # Note: Mac OS X 10.6 requires -SIGNALNAME before -u USER
-        command = ["killall", "-TERM", "-u", os.getenv("USER"), process_name]
+        try:
+            command = ["killall", "-TERM", "-u", os.environ["USER"], process_name]
+        except KeyError:
+            command = ["killall", "-TERM", process_name]
         # killall returns 1 if no process can be found and 2 on command error.
         # FIXME: We should pass a custom error_handler to allow only exit_code 1.
         # We should log in exit_code == 1
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to