zeroconf.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 #
3 # License: BSD
4 # https://raw.github.com/robotics-in-concert/rocon_multimaster/license/LICENSE
5 #
6 ##############################################################################
7 # Imports
8 ##############################################################################
9 
10 import subprocess
11 import sys
12 
13 # Delete this once we upgrade (hopefully anything after precise)
14 # Refer to https://github.com/robotics-in-concert/rocon_multimaster/issues/248
15 import threading
16 
17 # Ros imports
18 import rospy
19 
20 # Local imports
21 from . import utils
22 ##############################################################################
23 # Functions
24 ##############################################################################
25 
26 
27 def advertise_port_to_avahi(port, hub_name):
28  '''
29  Check if avahi-daemon is around and publish the redis server ip:port.
30  '''
31  # Check - assuming ubuntu here, robustify later
32  proc = subprocess.Popen(["pidof", "avahi-daemon"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
33  if proc.stdout.read() == "":
34  sys.exit(utils.logfatal("Hub : could not find the avahi-daemon - is it running?"))
35  sys.exit(utils.logfatal(" : if your isp is misbehaving and avahi not autostarting"))
36  sys.exit(utils.logfatal(" : you may need to set AVAHI_DAEMON_DETECT_LOCAL=0"))
37  sys.exit(utils.logfatal(" : in /etc/default/avahi-daemon"))
38 
39  # if you don't specify stdout/stderr streams, then it will automatically go to the background
40  # avahi-publish is a blocking call - it has to go to the background
41  # also note, we don't worry about cleaning it up as it will be killed with the parent process
42  subprocess.Popen(["avahi-publish", "-s", hub_name, "_ros-multimaster-hub._tcp", str(port)])
43  rospy.loginfo("Hub : advertising '" + hub_name + "' on zeroconf [_ros-multimaster-hub._tcp, port " + str(port) + "]")
def advertise_port_to_avahi(port, hub_name)
Functions.
Definition: zeroconf.py:27


rocon_hub
Author(s): Daniel Stonier , Jihoon Lee , Piyush Khandelwal
autogenerated on Mon Jun 10 2019 14:40:13