-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdependency_install.py
48 lines (42 loc) · 1.69 KB
/
dependency_install.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
import traceback
import sys
import subprocess
import config
from pipot.services import ServiceLoader, IService
services_to_enable = config.config_inst.get_services()
for service in services_to_enable:
class_name = service['name']
try:
instance = ServiceLoader.get_class_instance(
service['name'], None, service['config'])
if isinstance(instance, IService.IService):
print('Processing installation for %s' % service['name'])
apt_deps = instance.get_apt_dependencies()
if len(apt_deps) > 0:
apt = ['apt-get', '-q', '-y', 'install']
apt.extend(apt_deps)
print('Calling %s' % " ".join(apt))
# Call apt-get install
_ph = subprocess.Popen(apt)
_ph.wait()
else:
print('No apt dependencies for %s' % service['name'])
pip_deps = instance.get_pip_dependencies()
if len(pip_deps) > 0:
pip = ['pip', 'install']
pip.extend(pip_deps)
print('Calling %s' % " ".join(pip))
_ph = subprocess.Popen(pip)
_ph.wait()
else:
print('No pip dependencies for %s' % service['name'])
print('Running after_install_hook for %s: %s' % (
service['name'],
'success' if instance.after_install_hook() else 'failure'
)
)
else:
print('%s is not a IService; skipping')
except Exception as e:
print('Failed to load the %s service: %s' % (class_name,
traceback.format_exc()))