forked from kencoken/axes-lite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_components.py
executable file
·67 lines (52 loc) · 1.84 KB
/
get_components.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env python
"""
Get AXES-LITE components and store paths - see README.md for details
"""
import os
import subprocess
import json
from scaffoldutils import utils
with open(utils.COMPONENT_CFGS_FILE, 'r') as f:
component_opts = json.load(f)
ensure_dirs = [
component_opts['collection']['paths']['private_data'],
component_opts['collection']['paths']['public_data'],
component_opts['collection']['paths']['index_data'],
component_opts['collection']['paths']['index_data'] + '/db',
'logs'
]
component_repos = [
('git', 'cpuvisor-srv', 'https://github.com/kencoken/cpuvisor-srv.git', 'al-integration-prep'),
('git', 'imsearch-tools', 'https://github.com/kencoken/imsearch-tools.git'),
('git', 'medpackage', '--branch axes-lite --single-branch https://github.com/martin-xavier/medpackage.git'),
('hg' , 'limas', 'https://bitbucket.org/alyr/limas'),
('git', 'axes-home', 'https://github.com/kevinmcguinness/axes-home.git'),
('git', 'axes-research', 'https://github.com/kevinmcguinness/axes-research.git'),
]
def ensure_dir(path):
if not os.path.isdir(path):
os.mkdir(path)
def repo_clone(cmd, component, url, branch=None):
default_val = '<PATH>'
path = component_opts['components'][component]
if path is None or path == default_val:
return False
if os.path.isdir(path):
return False
clone_cmd = ' '.join([cmd, 'clone', url, path])
subprocess.call(clone_cmd, shell=True)
if branch:
with utils.change_cwd(path):
checkout_cmd = ' '.join([cmd, 'checkout', branch])
subprocess.call(checkout_cmd, shell=True)
return True
# main entry point
# ................
def main():
# Create dirs
map(ensure_dir, ensure_dirs)
# Clone repos
for repo in component_repos:
repo_clone(*repo)
if __name__ == '__main__':
main()