Package roslib :: Module rospack
[frames] | no frames]

Source Code for Module roslib.rospack

  1  # Software License Agreement (BSD License) 
  2  # 
  3  # Copyright (c) 2008, Willow Garage, Inc. 
  4  # All rights reserved. 
  5  # 
  6  # Redistribution and use in source and binary forms, with or without 
  7  # modification, are permitted provided that the following conditions 
  8  # are met: 
  9  # 
 10  #  * Redistributions of source code must retain the above copyright 
 11  #    notice, this list of conditions and the following disclaimer. 
 12  #  * Redistributions in binary form must reproduce the above 
 13  #    copyright notice, this list of conditions and the following 
 14  #    disclaimer in the documentation and/or other materials provided 
 15  #    with the distribution. 
 16  #  * Neither the name of Willow Garage, Inc. nor the names of its 
 17  #    contributors may be used to endorse or promote products derived 
 18  #    from this software without specific prior written permission. 
 19  # 
 20  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
 21  # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
 22  # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
 23  # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
 24  # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
 25  # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
 26  # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
 27  # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
 28  # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
 29  # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
 30  # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
 31  # POSSIBILITY OF SUCH DAMAGE. 
 32  # 
 33  # Revision $Id$ 
 34  # $Author$ 
 35   
 36  """ 
 37  Warning: do not use this library.  It is unstable and most of the routines 
 38  here have been superceded by other libraries (e.g. rospkg).  These 
 39  routines will likely be *deleted* in future releases. 
 40  """ 
 41   
 42  import os 
 43  import sys 
 44  import subprocess 
 45  import roslib.exceptions 
 46  import rospkg 
 47   
 48  if sys.hexversion > 0x03000000: #Python3 
 49      python3 = True 
 50  else: 
 51      python3 = False 
 52   
 53  import warnings 
 54  warnings.warn("roslib.rospack is deprecated, please use rospkg", stacklevel=2) 
 55   
56 -def rospackexec(args):
57 """ 58 @return: result of executing rospack command (via subprocess). string will be strip()ed. 59 @rtype: str 60 @raise roslib.exceptions.ROSLibException: if rospack command fails 61 """ 62 rospack_bin = 'rospack' 63 if python3: 64 val = subprocess.Popen([rospack_bin] + args, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[0] 65 val = val.decode().strip() 66 else: 67 val = (subprocess.Popen([rospack_bin] + args, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[0] or '').strip() 68 if val.startswith('rospack:'): #rospack error message 69 raise roslib.exceptions.ROSLibException(val) 70 return val
71
72 -def rospack_depends_on_1(pkg):
73 """ 74 @param pkg: package name 75 @type pkg: str 76 @return: A list of the names of the packages which depend directly on pkg 77 @rtype: list 78 """ 79 return rospackexec(['depends-on1', pkg]).split()
80
81 -def rospack_depends_on(pkg):
82 """ 83 @param pkg: package name 84 @type pkg: str 85 @return: A list of the names of the packages which depend on pkg 86 @rtype: list 87 """ 88 return rospackexec(['depends-on', pkg]).split()
89
90 -def rospack_depends_1(pkg):
91 """ 92 @param pkg: package name 93 @type pkg: str 94 @return: A list of the names of the packages which pkg directly depends on 95 @rtype: list 96 """ 97 return rospackexec(['deps1', pkg]).split()
98
99 -def rospack_depends(pkg):
100 """ 101 @param pkg: package name 102 @type pkg: str 103 @return: A list of the names of the packages which pkg depends on 104 @rtype: list 105 """ 106 return rospackexec(['deps', pkg]).split()
107
108 -def rospack_plugins(pkg):
109 """ 110 @param pkg: package name 111 @type pkg: str 112 @return: A list of the names of the packages which provide a plugin for pkg 113 @rtype: list 114 """ 115 val = rospackexec(['plugins', '--attrib=plugin', pkg]) 116 if val: 117 return [tuple(x.split(' ')) for x in val.split('\n')] 118 else: 119 return []
120
121 -def rosstackexec(args):
122 """ 123 @return: result of executing rosstack command (via subprocess). string will be strip()ed. 124 @rtype: str 125 @raise roslib.exceptions.ROSLibException: if rosstack command fails 126 """ 127 rosstack_bin = 'rosstack' 128 if python3: 129 val = subprocess.Popen([rosstack_bin] + args, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[0] 130 val = val.decode().strip() 131 else: 132 val = (subprocess.Popen([rosstack_bin] + args, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[0] or '').strip() 133 if val.startswith('rosstack:'): #rospack error message 134 raise roslib.exceptions.ROSLibException(val) 135 return val
136
137 -def rosstack_depends_on(s):
138 """ 139 @param s: stack name 140 @type s: str 141 @return: A list of the names of the stacks which depend on s 142 @rtype: list 143 """ 144 return rosstackexec(['depends-on', s]).split()
145
146 -def rosstack_depends_on_1(s):
147 """ 148 @param s: stack name 149 @type s: str 150 @return: A list of the names of the stacks which depend directly on s 151 @rtype: list 152 """ 153 return rosstackexec(['depends-on1', s]).split()
154
155 -def rosstack_depends(s):
156 """ 157 @param s: stack name 158 @type s: str 159 @return: A list of the names of the stacks which s depends on 160 @rtype: list 161 """ 162 return rosstackexec(['depends', s]).split()
163
164 -def rosstack_depends_1(s):
165 """ 166 @param s: stack name 167 @type s: str 168 @return: A list of the names of the stacks which s depends on directly 169 @rtype: list 170 """ 171 return rosstackexec(['depends1', s]).split()
172