-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgen_rosinstall.py
54 lines (42 loc) · 2.07 KB
/
gen_rosinstall.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
#!/usr/bin/env python
import sys
import cgi
import urllib
import os
import subprocess
import tempfile
import re
def main():
legacy_distro = ['cturtle', 'diamondback', 'electric']
print "Content-Type: text/html" # HTML is following
print # blank line, end of headers
form = cgi.FieldStorage()
keys = ['rosdistro', 'variant', 'overlay']
for k in keys:
if not k in form.keys():
return 'Missing parameters: %s'%k
if form['rosdistro'].value not in ['boxturtle', 'cturtle', 'diamondback', 'unstable', 'electric', 'fuerte']:
# needs to send httperror instead
return 'invalid rosdistro parameter'
if form['overlay'].value not in ['yes', 'no']:
# needs to send httperror instead
return 'invalid overlay parameter'
p = re.compile('\A[A-Za-z]+[\w\-]*\Z')
if not bool(p.match(form['variant'].value)):
# needs to send httperror instead
return 'invalid variant parameter'
# old legacy toolset in /home/willow/ros_release
if form['rosdistro'].value in legacy_distro:
command = 'export ROS_HOME=/tmp && export ROS_PACKAGE_PATH="/home/willow/ros_release:/opt/ros/cturtle/stacks" && export ROS_ROOT="/opt/ros/cturtle/ros" && export PATH="/opt/ros/cturtle/ros/bin:$PATH" && export PYTHONPATH="/opt/ros/cturtle/ros/core/roslib/src" && rosrun job_generation generate_rosinstall.py --rosdistro %s --variant %s --overlay %s --database /home/log/rosinstall.db'%(form['rosdistro'].value, form['variant'].value, form['overlay'].value)
# new pypi-based tools
else:
command = 'generate_rosinstall.py --rosdistro %s --variant %s --overlay %s --database /home/log/rosinstall.db'%(form['rosdistro'].value, form['variant'].value, form['overlay'].value)
helper = subprocess.Popen(['bash', '-c', command], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
res, err = helper.communicate()
if helper.returncode != 0:
return '%s'%str(err)
else:
print '%s'%str(res)
return 0
if __name__ == '__main__':
sys.exit(main())