Merge lp:~markgius/horizon/lp787222 into lp:~hudson-openstack/horizon/trunk

Proposed by Mark Gius
Status: Merged
Approved by: Devin Carlen
Approved revision: 50
Merged at revision: 50
Proposed branch: lp:~markgius/horizon/lp787222
Merge into: lp:~hudson-openstack/horizon/trunk
Diff against target: 159 lines (+61/-58)
1 file modified
openstack-dashboard/tools/install_venv.py (+61/-58)
To merge this branch: bzr merge lp:~markgius/horizon/lp787222
Reviewer Review Type Date Requested Status
Devin Carlen Approve
Review via email: mp+62049@code.launchpad.net

Description of the change

Whitespace changes only.

To post a comment you must log in.
Revision history for this message
Devin Carlen (devcamcar) wrote :

lgtm

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openstack-dashboard/tools/install_venv.py'
2--- openstack-dashboard/tools/install_venv.py 2011-05-14 00:07:04 +0000
3+++ openstack-dashboard/tools/install_venv.py 2011-05-23 22:53:23 +0000
4@@ -34,69 +34,72 @@
5
6
7 def die(message, *args):
8- print >>sys.stderr, message % args
9- sys.exit(1)
10+ print >> sys.stderr, message % args
11+ sys.exit(1)
12
13
14 def run_command(cmd, redirect_output=True, check_exit_code=True, cwd=ROOT):
15- """
16- Runs a command in an out-of-process shell, returning the
17- output of that command. Working directory is ROOT.
18- """
19- if redirect_output:
20- stdout = subprocess.PIPE
21- else:
22- stdout = None
23-
24- proc = subprocess.Popen(cmd, cwd=cwd, stdout=stdout)
25- output = proc.communicate()[0]
26- if check_exit_code and proc.returncode != 0:
27- die('Command "%s" failed.\n%s', ' '.join(cmd), output)
28- return output
29-
30-
31-HAS_EASY_INSTALL = bool(run_command(['which', 'easy_install'], check_exit_code=False).strip())
32-HAS_VIRTUALENV = bool(run_command(['which', 'virtualenv'], check_exit_code=False).strip())
33+ """
34+ Runs a command in an out-of-process shell, returning the
35+ output of that command. Working directory is ROOT.
36+ """
37+ if redirect_output:
38+ stdout = subprocess.PIPE
39+ else:
40+ stdout = None
41+
42+ proc = subprocess.Popen(cmd, cwd=cwd, stdout=stdout)
43+ output = proc.communicate()[0]
44+ if check_exit_code and proc.returncode != 0:
45+ die('Command "%s" failed.\n%s', ' '.join(cmd), output)
46+ return output
47+
48+
49+HAS_EASY_INSTALL = bool(run_command(['which', 'easy_install'],
50+ check_exit_code=False).strip())
51+HAS_VIRTUALENV = bool(run_command(['which', 'virtualenv'],
52+ check_exit_code=False).strip())
53
54
55 def check_dependencies():
56- """Make sure virtualenv is in the path."""
57+ """Make sure virtualenv is in the path."""
58
59- if not HAS_VIRTUALENV:
60- print 'not found.'
61- # Try installing it via easy_install...
62- if HAS_EASY_INSTALL:
63- print 'Installing virtualenv via easy_install...',
64- if not run_command(['which', 'virtualenv']):
65- die('ERROR: virtualenv not found.\n\nevelopment requires virtualenv,'
66- ' please install it using your favorite package management tool')
67- print 'done.'
68- print 'done.'
69+ if not HAS_VIRTUALENV:
70+ print 'not found.'
71+ # Try installing it via easy_install...
72+ if HAS_EASY_INSTALL:
73+ print 'Installing virtualenv via easy_install...',
74+ if not run_command(['which', 'virtualenv']):
75+ die('ERROR: virtualenv not found.\n\nevelopment requires'
76+ ' virtualenv, please install it using your favorite'
77+ ' package management tool')
78+ print 'done.'
79+ print 'done.'
80
81
82 def create_virtualenv(venv=VENV):
83- """Creates the virtual environment and installs PIP only into the
84- virtual environment
85- """
86- print 'Creating venv...',
87- run_command(['virtualenv', '-q', '--no-site-packages', VENV])
88- print 'done.'
89- print 'Installing pip in virtualenv...',
90- if not run_command([WITH_VENV, 'easy_install', 'pip']).strip():
91- die("Failed to install pip.")
92- print 'done.'
93+ """Creates the virtual environment and installs PIP only into the
94+ virtual environment
95+ """
96+ print 'Creating venv...',
97+ run_command(['virtualenv', '-q', '--no-site-packages', VENV])
98+ print 'done.'
99+ print 'Installing pip in virtualenv...',
100+ if not run_command([WITH_VENV, 'easy_install', 'pip']).strip():
101+ die("Failed to install pip.")
102+ print 'done.'
103
104
105 def install_dependencies(venv=VENV):
106- print 'Installing dependencies with pip (this can take a while)...'
107- run_command([WITH_VENV, 'pip', 'install', '-E', venv, '-r', PIP_REQUIRES],
108- redirect_output=False)
109+ print 'Installing dependencies with pip (this can take a while)...'
110+ run_command([WITH_VENV, 'pip', 'install', '-E', venv, '-r', PIP_REQUIRES],
111+ redirect_output=False)
112
113- # Tell the virtual env how to "import dashboard"
114- py = 'python%d.%d' % (sys.version_info[0], sys.version_info[1])
115- pthfile = os.path.join(venv, "lib", py, "site-packages", "dashboard.pth")
116- f = open(pthfile, 'w')
117- f.write("%s\n" % ROOT)
118+ # Tell the virtual env how to "import dashboard"
119+ py = 'python%d.%d' % (sys.version_info[0], sys.version_info[1])
120+ pthfile = os.path.join(venv, "lib", py, "site-packages", "dashboard.pth")
121+ f = open(pthfile, 'w')
122+ f.write("%s\n" % ROOT)
123
124
125 def install_django_openstack():
126@@ -112,7 +115,7 @@
127
128
129 def print_summary():
130- summary = """
131+ summary = """
132 OpenStack Dashboard development environment setup is complete.
133
134 To activate the virtualenv for the extent of your current shell session you
135@@ -120,16 +123,16 @@
136
137 $ source .dashboard-venv/bin/activate
138 """
139- print summary
140+ print summary
141
142
143 def main():
144- check_dependencies()
145- create_virtualenv()
146- install_dependencies()
147- install_django_openstack()
148- install_django_nova_syspanel()
149- print_summary()
150+ check_dependencies()
151+ create_virtualenv()
152+ install_dependencies()
153+ install_django_openstack()
154+ install_django_nova_syspanel()
155+ print_summary()
156
157 if __name__ == '__main__':
158- main()
159+ main()

Subscribers

People subscribed via source and target branches