1 from __future__
import print_function
7 ROS_CACHE_TIMEOUT_ENV_NAME =
'ROS_CACHE_TIMEOUT' 8 ROS_LOCATIONS_ENV_NAME =
'ROS_LOCATIONS' 10 ERROR_PREFIX =
'Error: ' 15 ros_location = os.environ.get(ROS_LOCATIONS_ENV_NAME)
16 if ros_location
is not None:
17 locations = ros_location.split(ROS_LOCATION_SEP)
21 if package_name == loc[:index]:
22 return 0, loc[index + 1:]
24 if package_name ==
'log':
25 p = subprocess.Popen(
'roslaunch-logs', stdout=subprocess.PIPE)
26 result_location = p.communicate()[0].strip()
27 result_code = p.returncode
28 return result_code, result_location
if result_code == 0
else '' 30 if package_name ==
'test_results':
31 p = subprocess.Popen(
'rosrun.bat rosunit test_results_dir.py', stdout=subprocess.PIPE)
32 result_location = p.communicate()[0].strip()
33 result_code = p.returncode
34 return result_code, result_location
if result_code == 0
else '' 38 env[ROS_CACHE_TIMEOUT_ENV_NAME] =
'-1.0' 39 p = subprocess.Popen([
'rospack',
'find', package_name], stdout=subprocess.PIPE)
40 result_location = p.communicate()[0].strip()
41 result_code = p.returncode
43 return result_code, result_location
45 p = subprocess.Popen([
'rosstack',
'find', package_name], stdout=subprocess.PIPE)
46 result_location = p.communicate()[0].strip()
47 result_code = p.returncode
49 return result_code, result_location
52 return result_code,
'' 60 parameters = os.path.normpath(argv[0]).split(os.path.sep)
61 package_name = parameters[0]
62 if len(parameters) > 1:
63 reldir = os.path.sep.join(parameters[1:])
65 if len(argv) < 2
or argv[1] !=
'forceeval':
66 print(ERROR_PREFIX +
'[' + package_name +
'] is not a valid argument!', file=sys.stderr)
71 print(ERROR_PREFIX +
'[' + package_name +
'] not found!', file=sys.stderr)
74 rosdir = os.path.normpath(os.path.sep.join([package_dir, reldir]))
79 if __name__ ==
'__main__':
def ros_location_find(package_name)