Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eliminate subprocess call #46

Closed
dmig opened this issue Jun 20, 2018 · 1 comment
Closed

eliminate subprocess call #46

dmig opened this issue Jun 20, 2018 · 1 comment
Labels
enhancement New feature or request
Milestone

Comments

@dmig
Copy link
Contributor

dmig commented Jun 20, 2018

This

user = subprocess.check_output("echo $(logname 2>/dev/null || echo $SUDO_USER)", shell=True).decode("ascii").strip()

Can be replaced with

try:
  user = os.getlogin()
except:
  user = os.environ.get('SUDO_USER')
@boltgolt boltgolt added the enhancement New feature or request label Jun 20, 2018
@boltgolt
Copy link
Owner

If i recall correctly i tried a load of different solutions for this and my line was the only one that worked in su. I'll give yours a spin though, it's much easier to maintain.

@boltgolt boltgolt added this to the Release 2.3.0 milestone Jun 20, 2018
boltgolt added a commit that referenced this issue Jun 28, 2018
@boltgolt boltgolt mentioned this issue Jun 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants