$search
00001 #!/usr/bin/python 00002 00003 from roslib import stack_manifest 00004 import roslib.stacks 00005 from jobs_common import * 00006 import sys 00007 import os 00008 import optparse 00009 import subprocess 00010 00011 00012 def main(): 00013 print "Starting run_auto_stack_devel script" 00014 00015 # parse command line options 00016 print "Parsing command line options" 00017 (options, args) = get_options(['stack', 'rosdistro'], ['repeat']) 00018 if not options: 00019 return -1 00020 if len(options.stack) > 1: 00021 print "You can only provide one stack at a time" 00022 return -1 00023 options.stack = options.stack[0] 00024 00025 # set environment 00026 print "Setting up environment" 00027 env = get_environment() 00028 env['ROS_PACKAGE_PATH'] = '%s:/opt/ros/%s/stacks'%(os.environ['WORKSPACE'], options.rosdistro) 00029 if options.stack == 'ros': 00030 env['ROS_ROOT'] = env['WORKSPACE']+'/ros' 00031 print "Changing ROS_ROOT and PYTHONPATH because we are building ROS" 00032 else: 00033 env['ROS_ROOT'] = '/opt/ros/%s/ros'%options.rosdistro 00034 env['PYTHONPATH'] = env['ROS_ROOT']+'/core/roslib/src' 00035 00036 env['PATH'] = '/opt/ros/%s/ros/bin:%s'%(options.rosdistro, os.environ['PATH']) 00037 00038 stack_dir = roslib.stacks.get_stack_dir(options.stack, env=env) 00039 #stack_dir = env['WORKSPACE']+'/'+options.stack 00040 00041 # Install Debian packages of stack dependencies 00042 print "Installing Debian packages of stack dependencies" 00043 call('sudo apt-get update', env) 00044 with open('%s/stack.xml'%stack_dir) as stack_file: 00045 depends = stack_manifest.parse(stack_file.read()).depends 00046 if len(depends) != 0: 00047 print 'Installing debian packages of stack dependencies: %s'%str(depends) 00048 call('sudo apt-get install %s --yes'%(stacks_to_debs(depends, options.rosdistro)), env, 00049 'Installing dependencies of stack "%s": %s'%(options.stack, str(depends))) 00050 00051 # Install system dependencies 00052 print 'Installing system dependencies' 00053 call('rosmake rosdep', env) 00054 call('rosdep install -y %s'%options.stack, env, 00055 'Installing system dependencies of stack %s'%options.stack) 00056 00057 00058 # Start Hudson Helper 00059 print 'Running Hudson Helper' 00060 res = 0 00061 for r in range(0, options.repeat+1): 00062 env['ROS_TEST_RESULTS_DIR'] = os.environ['ROS_TEST_RESULTS_DIR']+'/run_'+str(r) 00063 res_one = subprocess.call(('./hudson_helper --dir-test %s build'%stack_dir).split(' '), env=env) 00064 if res_one != 0: 00065 res = res_one 00066 return res 00067 00068 00069 if __name__ == '__main__': 00070 try: 00071 res = main() 00072 sys.exit( res ) 00073 except Exception: 00074 sys.exit(-1) 00075 00076 00077 00078