From 843709611fc517b1c29c7d83ee570d69dbd016bc Mon Sep 17 00:00:00 2001 From: Bruce Dawson Date: Thu, 21 Feb 2019 05:33:37 +0000 Subject: [PATCH] Support USERNAME as well as USER environment variable my_activity.py tries to determine the current user with the USER environment variable but on Windows it should use USERNAME. This change gets it to check both, which saves users from having to use the -u option and figure out what format the name should be in. Change-Id: Id2458d29f8a2635a96dd3859d6af0ed5aaea22bf Reviewed-on: https://chromium-review.googlesource.com/c/1479896 Reviewed-by: Dirk Pranke Commit-Queue: Bruce Dawson --- my_activity.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/my_activity.py b/my_activity.py index 77ee721e69..77b5f09c4c 100755 --- a/my_activity.py +++ b/my_activity.py @@ -857,7 +857,8 @@ def main(): parser = optparse.OptionParser(description=sys.modules[__name__].__doc__) parser.add_option( '-u', '--user', metavar='', - default=os.environ.get('USER'), + # Look for USER and USERNAME (Windows) environment variables. + default=os.environ.get('USER', os.environ.get('USERNAME')), help='Filter on user, default=%default') parser.add_option( '-b', '--begin', metavar='', @@ -1008,7 +1009,7 @@ def main(): if args: parser.error('Args unsupported') if not options.user: - parser.error('USER is not set, please use -u') + parser.error('USER/USERNAME is not set, please use -u') options.user = username(options.user) logging.basicConfig(level=options.verbosity)