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:
@@ -22,6 +22,14 @@ def install_my_kernel_spec(user=True):
|
|||||||
print('Installing IPython kernel spec')
|
print('Installing IPython kernel spec')
|
||||||
install_kernel_spec(td, 'bash', user=user, replace=True)
|
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):
|
def main(argv=None):
|
||||||
install_my_kernel_spec()
|
install_my_kernel_spec()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user