-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.py
More file actions
executable file
·50 lines (41 loc) · 1.32 KB
/
install.py
File metadata and controls
executable file
·50 lines (41 loc) · 1.32 KB
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
45
46
47
48
49
50
#!/usr/bin/env python
import glob
import os
import shutil
HOME_DIR = os.environ['HOME']
def install():
symlinks = glob.glob('*.symlink')
back_all = False
skip_all = False
over_all = False
for source in symlinks:
filename, _ = source.split('.')
dest = HOME_DIR + '/.' + filename
print 'Installing file %s' % filename
if os.path.lexists(dest):
if not (back_all or skip_all or over_all):
print 'File %s exists.' % dest
print 'Pick Action:'
print '[s/S]kip /All'
print '[o/O]verwrite /All'
print '[b/B]ack_up /All'
ans = raw_input()
if ans == 'S':
skip_all = True
elif ans == 'O':
over_all = True
elif ans == 'B':
back_all = True
if skip_all or ans == 's':
continue
elif over_all or ans == 'o':
try:
os.remove(dest)
except Exception:
shutil.rmtree(dest)
elif back_all or ans == 'b':
shutil.move(dest, dest + '.back')
# Create the link
os.symlink(os.path.realpath(source), dest)
if __name__ == '__main__':
install()