-
Notifications
You must be signed in to change notification settings - Fork 2
/
configure_project.py
96 lines (63 loc) · 2.34 KB
/
configure_project.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
"""Install and configure all requirements for running the gs-science project
from the git repository.
This is specific to Ubuntu. If you don't use Ubuntu, you must do the steps manually.
It is assumed that ssh keys have been set up at github.com and that git repository has been cloned e.g. using the command
git clone git@github.com:ingenieroariel/gs-science.git
"""
# Manual steps:
# python-pip does not exist in Ubuntu < Karmic, so one must get it manually from
# http://pypi.python.org/packages/source/p/pip/pip-0.7.2.tar.gz
# unpack in install with distutils: python setup.py install
import os
def run(cmd,
stdout=None,
stderr=None,
verbose=True):
s = cmd
if stdout:
s += ' > %s' % stdout
if stderr:
s += ' 2> %s' % stderr
if verbose:
print s
err = os.system(s)
if err != 0:
msg = 'Command "%s" failed with errorcode %i. ' % (cmd, err)
if stderr: msg += 'See logfile %s for details' % stderr
raise Exception(msg)
def install_ubuntu_packages():
"""Get required Ubuntu packages for geoserver.
It is OK if they are already installed
"""
print('Installing Ubuntu packages')
s = 'sudo apt-get clean'
run(s, verbose=True)
for package in ['python-setuptools']: #, 'python-pip']: # Pip not in Ubuntu pre-Karmic
#for package in ['python-setuptools', 'python-pip']:
s = 'sudo apt-get -y install %s' % package
log_base = '%s_install' % package
try:
run(s,
stdout=log_base + '.out',
stderr=log_base + '.err',
verbose=True)
except:
msg = 'Installation of package %s failed. ' % package
msg += 'See log file %s.out and %s.err for details' % (log_base, log_base)
raise Exception(msg)
#def clone_repository():
# """Get project from git repository.
# """
#
# s = 'git clone %s' % repository
# run(s)
def setup_environment():
"""Configure project enviroment
"""
s = 'sudo easy_install pip'
run(s)
s = 'sudo pip install -r requirements.txt'
run(s)
if __name__ == '__main__':
install_ubuntu_packages()
setup_environment()