Commit 84370961 authored by Bruce Dawson's avatar Bruce Dawson Committed by Commit Bot

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/1479896Reviewed-by: 's avatarDirk Pranke <dpranke@chromium.org>
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
parent 385c9b3a
......@@ -857,7 +857,8 @@ def main():
parser = optparse.OptionParser(description=sys.modules[__name__].__doc__)
parser.add_option(
'-u', '--user', metavar='<email>',
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='<date>',
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment