master_util.py
Go to the documentation of this file.
00001 import rospy
00002 import re
00003 import os
00004 
00005 previous_run_id = None
00006 
00007 
00008 def isMasterAlive():
00009     """
00010     return True if master alive and return False if
00011     master is not alive
00012     """
00013     global previous_run_id
00014     try:
00015         # first check the host is available
00016         master = rospy.get_master()
00017         master_host = re.search('http://([a-zA-Z0-9\-_]*):',
00018                                 master.getUri()[2]).groups(1)[0]
00019         response = os.system("ping -W 10 -c 1 " + master_host + " > /dev/null")
00020         if response != 0:
00021             print "master machine looks down"
00022             return False
00023         master.getSystemState()
00024         run_id = rospy.get_param("/run_id")
00025 
00026         if not previous_run_id:
00027             previous_run_id = run_id
00028         if run_id != previous_run_id:
00029             print "run_id is not same"
00030             previous_run_id = run_id
00031             return False
00032         return True
00033     except Exception, e:
00034         return False


jsk_topic_tools
Author(s): Kei Okada , Yusuke Furuta
autogenerated on Fri Sep 8 2017 03:38:56