Catch OSError(s) from os.getlogin() and fall back to looking at
environment variables to figure out the user's name. The OSError
is thrown where there is no tty for the python process when
os.getlogin() is called.
Related-Bug: #1221491
Change-Id: I2bd735c9669ba9d25da108da44ea602f358b2dcc