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_gateway_hub')
00016 import rospy
00017
00018
00019 from . import utils
00020
00021
00022
00023
00024
00025
00026 def advertise_port_to_avahi(port, hub_name):
00027 '''
00028 Check if avahi-daemon is around and publish the redis server ip:port.
00029 '''
00030
00031 proc = subprocess.Popen(["pidof", "avahi-daemon"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
00032 if proc.stdout.read() == "":
00033 sys.exit(utils.logfatal("Hub : could not find the avahi-daemon - is it running?"))
00034 sys.exit(utils.logfatal(" : if your isp is misbehaving and avahi not autostarting"))
00035 sys.exit(utils.logfatal(" : you may need to set AVAHI_DAEMON_DETECT_LOCAL=0"))
00036 sys.exit(utils.logfatal(" : in /etc/default/avahi-daemon"))
00037
00038
00039
00040
00041 subprocess.Popen(["avahi-publish", "-s", hub_name, "_ros-gateway-hub._tcp", str(port)])
00042 rospy.loginfo("Hub : advertising '" + hub_name + "' on zeroconf [_ros-gateway-hub._tcp, port " + str(port) + "]")