#2612: GetComponents assumes that $USER is defined
Reporter: Roland Haas Status: new Milestone: Version: development version Type: bug Priority: minor Component: GetComponents
Comment (by Roland Haas):
ugh, I did not know that. Checking… Simfactory has “workarounds”:
```python def GetUsername():
if "USER" not in os.environ: fd = simenv.popen("whoami") username = fd.read().strip() fd.close()
else: username = os.environ["USER"]
return username ```
What’s wrong with `os.getlogin()` which is the first answer that Google finds for “Python get user name”: [https://www.geeksforgeeks.org/how-to-get-the-current-username-in-python/%5D(...) and apparently part of Python since forever? I’ll make a pull request for simfactory as well.
-- Ticket URL: https://bitbucket.org/einsteintoolkit/tickets/issues/2612/getcomponents-assu...
trac@lists.einsteintoolkit.org