#NEWLINE# def slurmtime_to_seconds( tstr ) : #NEWLINE# #INDENT# 'Convert a slurm time to seconds, a float.\n\t\n\tSlurm times are MM:SS.SSS, HH:MM:SS, D-HH:MM:SS, etc.\n\t' #NEWLINE# t = 0.0 #NEWLINE# rest = tstr #NEWLINE# l = rest . split ( '-' ) #NEWLINE# if ( len ( l ) == 1 ) : #NEWLINE# #INDENT# rest = l [ 0 ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( len ( l ) == 2 ) : #NEWLINE# #INDENT# t += ( int ( l [ 0 ] ) * 86400 ) #NEWLINE# rest = l [ 1 ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise ValueError ( ( 'unable to parse time [%s]' % tstr ) ) #NEWLINE# #UNINDENT# #UNINDENT# l = rest . split ( ':' ) #NEWLINE# if ( len ( l ) == 2 ) : #NEWLINE# #INDENT# t += ( 60 * int ( l [ 0 ] ) ) #NEWLINE# t += float ( l [ 1 ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( len ( l ) == 3 ) : #NEWLINE# #INDENT# t += ( int ( l [ 0 ] ) * 3600 ) #NEWLINE# t += ( int ( l [ 1 ] ) * 60 ) #NEWLINE# t += int ( l [ 2 ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise ValueError ( ( 'unable to parse time [%s]' % tstr ) ) #NEWLINE# #UNINDENT# #UNINDENT# return t