retriever.py
Go to the documentation of this file.
00001 import roslib; roslib.load_manifest('resource_retriever')
00002 import rospy
00003 import subprocess
00004 import urlgrabber, string
00005 
00006 PACKAGE_PREFIX = 'package://'
00007 
00008 def rospack_find(package):
00009     process = subprocess.Popen(['rospack', 'find', package], shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
00010     (stdout, stderr) = process.communicate()
00011     if len(stderr) > 0:
00012         raise Exception(stderr)
00013     else:
00014         return string.strip(stdout)
00015 
00016 def get(url):
00017     mod_url = url
00018     if url.find(PACKAGE_PREFIX) == 0:
00019         mod_url = url[len(PACKAGE_PREFIX):]
00020         pos = mod_url.find('/')
00021         if pos == -1:
00022             raise Exception("Could not parse package:// format into file:// format for "+url)
00023 
00024         package = mod_url[0:pos]
00025         mod_url = mod_url[pos:]
00026         package_path = rospack_find(package)
00027 
00028         mod_url = "file://" + package_path + mod_url;
00029 
00030     return urlgrabber.urlopen(mod_url)  
00031 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends


resource_retriever
Author(s): Josh Faust (jfaust@willowgarage.com)
autogenerated on Mon Aug 19 2013 11:02:25