Added _is_root() Cross-platform way to check admin rights

http://stackoverflow.com/questions/1026431/cross-platform-way-to-check-admin-rights-in-a-python-script-under-windows
This commit is contained in:
Carl Osterwisch
2015-09-10 12:26:43 -04:00
parent 25b219314c
commit 764ed0fdc4
+8
View File
@@ -22,6 +22,14 @@ def install_my_kernel_spec(user=True):
print('Installing IPython kernel spec')
install_kernel_spec(td, 'bash', user=user, replace=True)
def _is_root():
"""Cross-platform way to check admin rights"""
import ctypes, os
try:
return os.geteuid() == 0
except AttributeError:
return ctypes.windll.shell32.IsUserAnAdmin() != 0
def main(argv=None):
install_my_kernel_spec()