Here's the program:
if os.name == 'posix' and getpass.getuser() != 'root':
from subprocess import call
call(["sudo", sys.executable, os.path.realpath(__file__), "--root-install"])
When I run it from the terminal it works fine:
> [sudo] Password for user:
But when I run it from PyCharm the terminal just stays blank.
I have also tried setting stdin=sys.stdin, stdout=sys.stdout manually, but that did not change anything.
What am I doing wrong here?
pexpect: stackoverflow.com/questions/18046508/…sudo, but then how would I aquire said password?getpass.getpassdoes not seem to work in PyCharm either.getpassalso needs the original terminal. You could try to detect it, and if not a normal terminal (testing forhasattr(sys.stdin,"isatty")) and if it's not a normal terminal, use some GUI like wx or tk to prompt for a password (hiding the letters)hasattr(sys.stdin,"isatty")is alwaysTrue. Both in a normal terminal and in PyCharms. Alternatives?hasattr(sys.stdin,"fileno")