#NEWLINE# def list_loaded( args ) : #NEWLINE# #INDENT# programs = sorted ( Program . find_for_user ( ) , key = sort_key ) #NEWLINE# for prog in programs : #NEWLINE# #INDENT# if prog . is_running : #NEWLINE# #INDENT# start_time = prog . state . get ( 'start_time' ) #NEWLINE# if start_time : #NEWLINE# #INDENT# td = str ( timedelta ( seconds = ( time . time ( ) - start_time ) ) ) . rsplit ( '.' , 1 ) [ 0 ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# td = '?' #NEWLINE# #UNINDENT# ctx = ( prog . data [ 'name' ] [ : 24 ] , prog . text_status , prog . state . get ( 'child_pid' ) , td ) #NEWLINE# print ( ( '%-25s %-15s pid %-6s, uptime %s' % ctx ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# stop_time = prog . state . get ( 'stop_time' ) #NEWLINE# if stop_time : #NEWLINE# #INDENT# td = ( 'downtime ' + str ( timedelta ( seconds = ( time . time ( ) - stop_time ) ) ) . rsplit ( '.' , 1 ) [ 0 ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# td = '' #NEWLINE# #UNINDENT# reason = prog . state . get ( 'reason' , '' ) #NEWLINE# ctx = ( prog . data [ 'name' ] [ : 35 ] , prog . text_status , reason ) #NEWLINE# print ( ( '%-25s %-15s %s' % ctx ) ) #NEWLINE# if td : #NEWLINE# #INDENT# print ( ( ' ' * 41 ) , td ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( not programs ) : #NEWLINE# #INDENT# print ( 'No programs added' )