-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
executable file
·48 lines (35 loc) · 891 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
45
46
47
48
#!/usr/bin/env python3
import os
from pathlib import Path
GIT = Path(__file__).resolve().parent
HOME = Path('~').expanduser()
ANSIBLE = HOME / '.ansible'
CFG = 'ansible.cfg'
CFG_HIDDEN = '.' + CFG
SCRIPTS = Path('bin/ans')
SCRIPT_SUFFIXES = ['p', 'v']
TASKS = {}
TASKS['link_ansible_dir'] = {
'args': [GIT, ANSIBLE],
}
TASKS['link_home_cfg'] = {
'args': [ANSIBLE / CFG, HOME / CFG_HIDDEN],
}
for suffix in SCRIPT_SUFFIXES:
script = SCRIPTS.with_name(SCRIPTS.name + suffix)
TASKS[f'link_script_{suffix}'] = {
'args': [GIT / script, HOME / script],
}
def main(tasks):
for task in tasks.values():
make(**task)
print('run: "sudo -H pip3 install ansible"')
def make(func=os.symlink, args=None, kwargs=None):
args = args or []
kwargs = kwargs or {}
try:
func(*args, **kwargs)
except FileExistsError:
pass
if __name__ == '__main__':
main(TASKS)