$search
00001 #!/usr/bin/env python 00002 00003 import sys 00004 import cgi 00005 import urllib 00006 import os 00007 import subprocess 00008 import tempfile 00009 00010 import cgitb 00011 cgitb.enable() 00012 00013 00014 # Assemble a dictionary of stacks. 00015 def find_stacks(form): 00016 if 'email' not in form.keys(): 00017 print "<H1>Error</H1>" 00018 print "Please fill in email address." 00019 return None 00020 email = form['email'].value 00021 00022 if 'distro' not in form.keys(): 00023 print "<H1>Error</H1>" 00024 print "Please select a valid distribution." 00025 return None 00026 distro = form['distro'].value 00027 00028 import re 00029 stack_form = re.compile('stack_([0-9]*)') 00030 stacks = [] 00031 for k in form.keys(): 00032 match = stack_form.match(k) 00033 if match: 00034 stacks.append(form['stack_%d'%int(match.group(1))].value) 00035 if len(stacks) == 0: 00036 print "<H1>Error</H1>" 00037 print "Please specify the stack(s) to test." 00038 return None 00039 00040 return distro, email, stacks 00041 00042 00043 def main(): 00044 legacy_distro = ['cturtle', 'diamondback', 'electric'] 00045 00046 print "Content-Type: text/html" # HTML is following 00047 print # blank line, end of headers 00048 00049 form = cgi.FieldStorage() 00050 00051 ret = find_stacks(form) 00052 if not ret: 00053 print '<p><a href="/hudson-html/hudson_kick_off.html">Try again</a>' 00054 return 00055 distro, email, stacks = ret 00056 00057 f = open('/var/www/hds.xml') 00058 info = f.read().split(',') 00059 00060 command = "" 00061 # old legacy toolset in /home/willow/ros_release 00062 if distro in legacy_distro: 00063 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_prerelease.py %s %s --repeat 0 --email %s --rosdistro %s'%(info[0], info[1], email, distro) 00064 00065 # new pypi-based tools 00066 else: 00067 command = 'generate_prerelease.py %s %s --repeat 0 --email %s --rosdistro %s'%(info[0], info[1], email, distro) 00068 00069 for s in stacks: 00070 command += ' --stack %s'%s 00071 00072 res, err = subprocess.Popen(['bash', '-c', command], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() 00073 res = res.replace('<', '<a href="') 00074 res = res.replace('>', '">the Hudson server</a>') 00075 res = res.replace('\n', '<br>') 00076 print '<h1>Your request was sent to the Hudson server</h1> <p> %s %s'%(str(res), str(err)) 00077 00078 if __name__ == '__main__': 00079 main()