#NEWLINE# @ webapp . route ( '/process/<int:pid>' , defaults = { #NEWLINE# #INDENT# 'section' : 'overview' , #NEWLINE# #UNINDENT# } ) #NEWLINE# @ webapp . route ( '/process/<int:pid>/<string:section>' ) #NEWLINE# def process( pid , section ) : #NEWLINE# #INDENT# valid_sections = [ 'overview' , 'threads' , 'files' , 'connections' , 'memory' , 'environment' , 'children' , 'limits' ] #NEWLINE# if ( section not in valid_sections ) : #NEWLINE# #INDENT# errmsg = ( 'Invalid subsection when trying to view process %d' % pid ) #NEWLINE# return ( render_template ( 'error.html' , error = section ) , 404 ) #NEWLINE# #UNINDENT# context = { #NEWLINE# #INDENT# 'process' : current_service . get_process ( pid ) , #NEWLINE# 'section' : section , #NEWLINE# 'page' : 'processes' , #NEWLINE# 'is_xhr' : request . is_xhr , #NEWLINE# #UNINDENT# } #NEWLINE# if ( section == 'environment' ) : #NEWLINE# #INDENT# penviron = current_service . get_process_environment ( pid ) #NEWLINE# whitelist = current_app . config . get ( 'PSDASH_ENVIRON_WHITELIST' ) #NEWLINE# if whitelist : #NEWLINE# #INDENT# penviron = dict ( ( ( k , ( v if ( k in whitelist ) else '*hidden by whitelist*' ) ) for ( k , v ) in penviron . iteritems ( ) ) ) #NEWLINE# #UNINDENT# context [ 'process_environ' ] = penviron #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( section == 'threads' ) : #NEWLINE# #INDENT# context [ 'threads' ] = current_service . get_process_threads ( pid ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( section == 'files' ) : #NEWLINE# #INDENT# context [ 'files' ] = current_service . get_process_open_files ( pid ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( section == 'connections' ) : #NEWLINE# #INDENT# context [ 'connections' ] = current_service . get_process_connections ( pid ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( section == 'memory' ) : #NEWLINE# #INDENT# context [ 'memory_maps' ] = current_service . get_process_memory_maps ( pid ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( section == 'children' ) : #NEWLINE# #INDENT# context [ 'children' ] = current_service . get_process_children ( pid ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( section == 'limits' ) : #NEWLINE# #INDENT# context [ 'limits' ] = current_service . get_process_limits ( pid ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# return render_template ( ( 'process/%s.html' % section ) , ** context )