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 import sys 46 47 python_prefix = 'python' 48 if sys.version_info[0] == 3: 49 python_prefix += '3' 50 51 #A dictionary of core ROS python packages and their corresponding .deb packages 52 py_to_deb_core_packages = { 53 'catkin_pkg': '%s-catkin-pkg' % python_prefix, 54 'rospkg': '%s-rospkg' % python_prefix, 55 'rosdep2': '%s-rosdep' % python_prefix, 56 } 57 # optional ROS python packages and their corresponding .deb packages 58 py_to_deb_optional_packages = { 59 'rosinstall': '%s-rosinstall' % python_prefix, 60 } 61 62 #A dictionary of release ROS python packages and their corresponding .deb packages 63 py_to_deb_release_packages = { 64 'bloom': '%s-bloom' % python_prefix, 65 'rosrelease': '%s-rosrelease' % python_prefix, 66 } 67 6870 """Determines the name of the host operating system""" 71 import rospkg.os_detect 72 os_detector = rospkg.os_detect.OsDetect() 73 return (os_detector.detect_os())[0]74 75 79 8082 """Uses dpkg to determine if a package has been installed""" 83 return (subprocess.call( 84 'dpkg -l ' + deb_pkg, 85 shell=True, 86 stdout=subprocess.PIPE, 87 stderr=subprocess.PIPE) == 0)88 8991 """Indicates if a path (either directory or file) is in the same place 92 pip installs Python code""" 93 return ('/usr/local' in path)94 9597 """Indicates if a Python package is importable in the current 98 environment.""" 99 try: 100 importlib.import_module(python_pkg) 101 return True 102 except ImportError: 103 return False104 105107 """Indicates if am importable package has been installed through pip on 108 Ubuntu""" 109 try: 110 pkg_handle = importlib.import_module(python_pkg) 111 return is_a_pip_path_on_ubuntu(pkg_handle.__file__) 112 except ImportError: 113 return False114 115 116 # Error/Warning Rules118 """Make sure core Python modules are installed""" 119 warn_str = '' 120 for py_pkg in py_to_deb_core_packages: 121 if not is_python_package_installed(py_pkg): 122 warn_str = warn_str + py_pkg + ' -- ' 123 if (warn_str != ''): 124 return warn_str125 126128 """Make sure on Debian python packages are installed""" 129 if (is_host_os_ubuntu()): 130 warn_str = '' 131 for py_pkg in py_to_deb_core_packages: 132 deb_pkg = py_to_deb_core_packages[py_pkg] 133 if not is_debian_package_installed(deb_pkg): 134 warn_str = warn_str + py_pkg + ' (' + deb_pkg + ') -- ' 135 if (warn_str != ''): 136 return warn_str137 138140 """Make sure on Ubuntu, Python packages are install with apt and not pip""" 141 if (is_host_os_ubuntu()): 142 warn_str = '' 143 pt_to_deb_package_names = list(py_to_deb_core_packages.keys()) + \ 144 list(py_to_deb_optional_packages.keys()) + list(py_to_deb_release_packages.keys()) 145 for py_pkg in pt_to_deb_package_names: 146 if is_python_package_installed_via_pip_on_ubuntu(py_pkg): 147 warn_str = warn_str + py_pkg + ' -- ' 148 if (warn_str != ''): 149 return warn_str150 151 warnings = [ 152 (python_module_install_check, 153 "You are missing core ROS Python modules: "), 154 (pip_install_check_on_ubuntu, 155 "You have pip installed packages on Ubuntu, " 156 "remove and install using Debian packages: "), 157 (deb_install_check_on_ubuntu, 158 "You are missing Debian packages for core ROS Python modules: "), 159 ] 160 161 errors = [] 162 163165 """Check implementation function for roswtf""" 166 from roswtf.rules import warning_rule, error_rule 167 for r in warnings: 168 warning_rule(r, r[0](ctx), ctx) 169 for r in errors: 170 error_rule(r, r[0](ctx), ctx)171
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Sun Feb 3 11:30:32 2019 | http://epydoc.sourceforge.net |