Home | Trees | Indices | Help |
---|
|
1 # Software License Agreement (BSD License) 2 # 3 # Copyright (c) 2009, 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: environment.py 4428 2009-05-05 05:48:36Z jfaustwg $ 34 35 import os 36 import socket 37 import stat 38 import string 39 import sys 40 41 from roswtf.rules import warning_rule, error_rule 42 43 # #122045 import roslib.network 46 import socket 47 # best we can do is compare roslib's routine against socket resolution and make sure they agree 48 addrs = roslib.network.get_local_addresses() 49 50 resolved = socket.gethostbyname(socket.gethostname()) 51 if not resolved.startswith('127.') and resolved not in addrs: 52 return "Local hostname [%s] resolves to [%s], which does not appear to be a local IP address %s."%(socket.gethostname(), resolved, str(addrs))53 54 # suggestion by mquigley based on laptop dhcp issues56 """Make sure that ROS_HOSTNAME resolves to a local IP address""" 57 import roslib.rosenv 58 if not roslib.rosenv.ROS_HOSTNAME in ctx.env: 59 return 60 61 import roslib.network 62 import socket 63 64 hostname = ctx.env[roslib.rosenv.ROS_HOSTNAME] 65 try: 66 resolved = socket.gethostbyname(hostname) 67 except socket.gaierror: 68 return "ROS_HOSTNAME [%s] cannot be resolved to an IP address"%(hostname) 69 70 # best we can do is compare roslib's routine against socket resolution and make sure they agree 71 addrs = roslib.network.get_local_addresses() 72 73 if resolved not in addrs: 74 return "ROS_HOSTNAME [%s] resolves to [%s], which does not appear to be a local IP address %s."%(hostname, resolved, str(addrs))7577 """Make sure that ROS_IP is a local IP address""" 78 import roslib.rosenv 79 if not roslib.rosenv.ROS_IP in ctx.env: 80 return 81 82 import roslib.network 83 import socket 84 85 ip = ctx.env[roslib.rosenv.ROS_IP] 86 87 # best we can do is compare roslib's routine against socket resolution and make sure they agree 88 addrs = roslib.network.get_local_addresses() 89 90 if ip not in addrs: 91 return "ROS_IP [%s] does not appear to be a local IP address %s."%(ip, str(addrs))92 93 # Error/Warning Rules 94 95 warnings = [ 96 (ros_hostname_check, 97 "ROS_HOSTNAME may be incorrect: "), 98 (ros_ip_check, 99 "ROS_IP may be incorrect: "), 100 101 ] 102 103 errors = [ 104 (ip_check, 105 "Local network configuration is invalid: "), 106 ] 107109 for r in warnings: 110 warning_rule(r, r[0](ctx), ctx) 111 for r in errors: 112 error_rule(r, r[0](ctx), ctx)113
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Fri Jan 11 10:12:18 2013 | http://epydoc.sourceforge.net |