master_util.py
Go to the documentation of this file.
1 # -*- coding: utf-8 -*-
2 
3 import urlparse
4 import rospy
5 import os
6 
7 previous_run_id = None
8 
9 
11  """
12  return True if master alive and return False if
13  master is not alive
14  """
15  global previous_run_id
16  try:
17  # first check the host is available
18  master_host = urlparse.urlsplit(rospy.core.rosgraph.get_master_uri()).hostname
19  response = os.system("ping -W 10 -c 1 " + master_host + " > /dev/null")
20  if response != 0:
21  print "master machine looks down"
22  return False
23  assert 1 == rospy.get_master().getSystemState()[0]
24  run_id = rospy.get_param("/run_id")
25 
26  if not previous_run_id:
27  previous_run_id = run_id
28  if run_id != previous_run_id:
29  print "run_id is not same"
30  previous_run_id = run_id
31  return False
32  return True
33  except Exception, e:
34  return False


jsk_topic_tools
Author(s): Kei Okada , Yusuke Furuta
autogenerated on Tue Feb 6 2018 03:45:19