Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 import subprocess
00011 import sys
00012 
00013 
00014 import roslib
00015 roslib.load_manifest('rocon_hub')
00016 import rospy
00017 
00018 
00019 from . import utils
00020 
00021 
00022 
00023 
00024 
00025 def advertise_port_to_avahi(port, hub_name):
00026     '''
00027       Check if avahi-daemon is around and publish the redis server ip:port.
00028     '''
00029     
00030     proc = subprocess.Popen(["pidof", "avahi-daemon"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
00031     if proc.stdout.read() == "":
00032         sys.exit(utils.logfatal("Hub : could not find the avahi-daemon - is it running?"))
00033         sys.exit(utils.logfatal("    : if your isp is misbehaving and avahi not autostarting"))
00034         sys.exit(utils.logfatal("    : you may need to set AVAHI_DAEMON_DETECT_LOCAL=0"))
00035         sys.exit(utils.logfatal("    : in /etc/default/avahi-daemon"))
00036 
00037     
00038     
00039     
00040     subprocess.Popen(["avahi-publish", "-s", hub_name, "_ros-multimaster-hub._tcp", str(port)])
00041     rospy.loginfo("Hub : advertising '" + hub_name + "' on zeroconf [_ros-multimaster-hub._tcp, port " + str(port) + "]")