-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsetup.py
44 lines (33 loc) · 1010 Bytes
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#/usr/bin/python
#coding=utf8
import os
import sys
def authenticate():
'''Prompt the user for the superuser password if required.'''
# The euid (effective user id) of the superuser is 0.
euid = os.geteuid()
if euid != 0:
args = ['sudo', '-E', sys.executable] + sys.argv[:] + [os.environ]
# Replaces the current running process with the sudo authentication.
os.execlpe('sudo', *args)
return True
def setup():
'''Install drake.'''
authenticate()
os.system('rm -rf ~/.drake')
os.system('cp -Rf ../drake/ ~/.drake')
os.system('chmod +x ~/.drake/drake.py')
os.system('ln -fs ~/.drake/drake.py /usr/bin/drake')
def remove():
'''Uninstall drake.'''
authenticate()
os.system('rm -rf ~/.drake')
os.system('rm -f /usr/bin/drake')
def main():
if len(sys.argv) > 1:
if sys.argv[1] == 'install':
setup()
elif sys.argv[1] == 'uninstall':
remove()
if __name__ == '__main__':
main()