Skip to content

Commit 09bfa79

Browse files
committed
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. Canonical link: https://commits.webkit.org/236851@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276374 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 99f888f commit 09bfa79

3 files changed

Lines changed: 28 additions & 2 deletions

File tree

Tools/ChangeLog

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
2021-04-21 Sam Sneddon <gsnedders@apple.com>
2+
3+
Handle os.getenv returning None
4+
https://bugs.webkit.org/show_bug.cgi?id=224869
5+
6+
Reviewed by Jonathan Bedard.
7+
8+
* Scripts/webkitpy/common/checkout/scm/svn.py:
9+
(SVNRepository.has_authorization_for_realm): This entirely replaces reading
10+
$HOME with a call to os.path.expanduser. Notably, the stdlib function both
11+
handles cases on Unix-like OSes when $HOME is undefined and on Windows (where
12+
$HOME is undefined by default) correctly constructs the path.
13+
* Scripts/webkitpy/common/system/executive.py:
14+
(Executive.kill_all): Handle $USER being undefined by just attempting to kill
15+
all processes regardless of owner.
16+
117
2021-04-21 Simon Fraser <simon.fraser@apple.com>
218

319
Enhance scrolling-related trace points

Tools/Scripts/webkitpy/common/checkout/scm/svn.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,17 @@ class SVNRepository(object):
5353
svn_server_host = svn_server_host
5454
svn_server_realm = svn_server_realm
5555

56-
def has_authorization_for_realm(self, realm, home_directory=os.getenv("HOME")):
56+
def has_authorization_for_realm(self, realm, home_directory=None):
5757
# If we are working on a file:// repository realm will be None
5858
if realm is None:
5959
return True
60+
61+
# Find the user's home directory
62+
if home_directory is None:
63+
home_directory = os.path.expanduser("~")
64+
if home_directory == "~":
65+
return False
66+
6067
# ignore false positives for methods implemented in the mixee class. pylint: disable=E1101
6168
# Assumes find and grep are installed.
6269
if not os.path.isdir(os.path.join(home_directory, ".subversion")):

Tools/Scripts/webkitpy/common/system/executive.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,10 @@ def kill_all(self, process_name):
354354
# uses KILL. Windows is always using /f (which seems like -KILL).
355355
# We should pick one mode, or add support for switching between them.
356356
# Note: Mac OS X 10.6 requires -SIGNALNAME before -u USER
357-
command = ["killall", "-TERM", "-u", os.getenv("USER"), process_name]
357+
try:
358+
command = ["killall", "-TERM", "-u", os.environ["USER"], process_name]
359+
except KeyError:
360+
command = ["killall", "-TERM", process_name]
358361
# killall returns 1 if no process can be found and 2 on command error.
359362
# FIXME: We should pass a custom error_handler to allow only exit_code 1.
360363
# We should log in exit_code == 1

0 commit comments

Comments
 (0)