Home | Trees | Indices | Help |
---|
|
1 # Software License Agreement (BSD License) 2 # 3 # Copyright (c) 2012, 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 """ 34 Checks to see if core Python scripts have: 35 1) Been installed 36 2) Have been installed via Debians on Ubuntu 37 3) Have not been installed via pip on Ubuntu 38 """ 39 40 from __future__ import print_function 41 42 import subprocess 43 import importlib 44 import os 45 46 #A dictionary of core ROS python packages and their corresponding .deb packages 47 py_to_deb_core_packages = { 48 'catkin_pkg': 'python-catkin-pkg', 49 'rospkg': 'python-rospkg', 50 'rosinstall': 'python-rosinstall', 51 'rosdep2': 'python-rosdep', 52 } 53 54 #A dictionary of release ROS python packages and their corresponding .deb packages 55 py_to_deb_release_packages = { 56 'bloom': 'python-bloom', 57 'rosrelease': 'python-rosrelease', 58 } 59 6062 """Determines the name of the host operating system""" 63 import rospkg.os_detect 64 os_detector = rospkg.os_detect.OsDetect() 65 return (os_detector.detect_os())[0]66 67 71 7274 """Uses dpkg to determine if a package has been installed""" 75 return (subprocess.call( 76 'dpkg -l ' + deb_pkg, 77 shell=True, 78 stdout=subprocess.PIPE, 79 stderr=subprocess.PIPE) == 0)80 8183 """Indicates if a path (either directory or file) is in the same place 84 pip installs Python code""" 85 return ('/usr/local' in path)86 8789 """Indicates if a Python package is importable in the current 90 environment.""" 91 try: 92 importlib.import_module(python_pkg) 93 return True 94 except ImportError: 95 return False96 9799 """Indicates if am importable package has been installed through pip on 100 Ubuntu""" 101 try: 102 pkg_handle = importlib.import_module(python_pkg) 103 return is_a_pip_path_on_ubuntu(pkg_handle.__file__) 104 except ImportError: 105 return False106 107 108 # Error/Warning Rules110 """Make sure core Python modules are installed""" 111 warn_str = '' 112 for py_pkg in py_to_deb_core_packages: 113 if not is_python_package_installed(py_pkg): 114 warn_str = warn_str + py_pkg + ' -- ' 115 if (warn_str != ''): 116 return warn_str117 118120 """Make sure on Debian python packages are installed""" 121 if (is_host_os_ubuntu()): 122 warn_str = '' 123 for py_pkg in py_to_deb_core_packages: 124 deb_pkg = py_to_deb_core_packages[py_pkg] 125 if not is_debian_package_installed(deb_pkg): 126 warn_str = warn_str + py_pkg + ' (' + deb_pkg + ') -- ' 127 if (warn_str != ''): 128 return warn_str129 130132 """Make sure on Ubuntu, Python packages are install with apt and not pip""" 133 if (is_host_os_ubuntu()): 134 warn_str = '' 135 for py_pkg in dict(py_to_deb_core_packages.items() + py_to_deb_core_packages.items()): 136 if is_python_package_installed_via_pip_on_ubuntu(py_pkg): 137 warn_str = warn_str + py_pkg + ' -- ' 138 if (warn_str != ''): 139 return warn_str140 141 warnings = [ 142 (python_module_install_check, 143 "You are missing core ROS Python modules: "), 144 (pip_install_check_on_ubuntu, 145 "You have pip installed packages on Ubuntu, " 146 "remove and install using Debian packages: "), 147 (deb_install_check_on_ubuntu, 148 "You are missing Debian packages for core ROS Python modules: "), 149 ] 150 151 errors = [] 152 153155 """Check implementation function for roswtf""" 156 from roswtf.rules import warning_rule, error_rule 157 for r in warnings: 158 warning_rule(r, r[0](ctx), ctx) 159 for r in errors: 160 error_rule(r, r[0](ctx), ctx)161
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Fri Aug 28 12:34:24 2015 | http://epydoc.sourceforge.net |