6 from rosmsg
import list_types
12 DOT_ROS_FOLDER = os.path.expanduser(
'~/.ros')
13 PY_DEP_FILENAME = os.path.join(DOT_ROS_FOLDER,
'py_deps.yaml')
20 if os.path.exists(PY_DEP_FILENAME):
21 PYTHON_DEPS = yaml.safe_load(open(PY_DEP_FILENAME))
22 if 'last_download' in PYTHON_DEPS:
23 now = datetime.datetime.now()
24 if now - PYTHON_DEPS[
'last_download'] < datetime.timedelta(days=3):
28 ff = requests.get(
'https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml').text
29 except requests.exceptions.ConnectionError:
30 print(
'Cannot retrieve latest python dependencies')
33 PYTHON_DEPS = yaml.safe_load(ff)
34 PYTHON_DEPS[
'last_download'] = datetime.datetime.now()
36 if not os.path.exists(DOT_ROS_FOLDER):
37 os.mkdir(DOT_ROS_FOLDER)
38 yaml.dump(PYTHON_DEPS, open(PY_DEP_FILENAME,
'w'))
42 for var
in [key,
'python-' + key,
'python3-' + key, key.replace(
'python-',
'python3-'), key.replace(
'python-',
''),
43 key.replace(
'python-',
'').replace(
'-',
'_')]:
44 if var
in PYTHON_DEPS:
55 rospack = rospkg.RosPack()
56 for pkg
in rospack.list():
58 for mode, ros_set
in [(
'.msg', MESSAGES), (
'.srv', SERVICES)]:
59 for gen_key
in list_types(pkg, mode, rospack):
60 pkg, gen = gen_key.split(
'/')
61 ros_set.add((pkg, gen))
65 return pkg
in PACKAGES
69 return (pkg, msg)
in MESSAGES
73 return (pkg, srv)
in SERVICES
def get_python_dependency(key)
def maybe_download_python_deps()