00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 import math
00039 import time
00040
00041 def write_table_row(lst, bold = False):
00042 """
00043 Writes list into HTML table row
00044 @param lst list : List of items to write
00045 @param bold bool : True if row text should be bold
00046 """
00047 html = ['<tr>']
00048 for val in lst:
00049 if bold:
00050 html.append('<td><b>%s</b></td>' % val)
00051 else:
00052 html.append('<td>%s</td>' % val)
00053
00054 html.append('</tr>')
00055
00056 return ''.join(html)
00057
00058
00059 def get_duration_str(duration):
00060 """
00061 Returns duration in a formatted manner
00062 @param duration float : Time in seconds
00063 @return string "HOURShr, MINm"
00064 """
00065 hrs = max(math.floor(duration / 3600), 0)
00066 min = max(math.floor(duration / 6), 0) / 10 - hrs * 60
00067
00068 return "%dhr, %.1fm" % (hrs, min)
00069
00070
00071 def format_localtime(stamp):
00072 """
00073 Formats a rospy.get_time() stamp in a human readable local time
00074 @param stamp float : From rospy.get_time()
00075 """
00076 return time.strftime("%m/%d/%Y %H:%M:%S", time.localtime(stamp))
00077
00078 def format_localtime_file(stamp):
00079 """
00080 Formats a rospy.get_time() stamp in a filename-OK format
00081 @param stamp float : From rospy.get_time()
00082 """
00083 return time.strftime("%m-%d-%Y_%H-%M-%S", time.localtime(stamp))
00084
00085 def clean_filename(filename):
00086 """
00087 Formats a filename to remove any ' ' or '-'
00088 @param filename str : Filename to clean
00089 @return str : Cleaned up name
00090 """
00091 return filename.replace(' ', '_').replace('/', '-')