I have a problem. I am writing a piece of software, which is required to perform an operation which requires the user to be in sudo mode. running \'sudo python filename.py\'
Don't try and make yourself sudo just check if you are and error if your not
class NotSudo(Exception): pass if os.getuid() != 0: raise NotSudo("This program is not run as sudo or elevated this it will not work")