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