#NEWLINE# @ AccessCheck #NEWLINE# def stopPacketCapture( self , dev ) : #NEWLINE# #INDENT# 'Stop a tcpdump process that was started with startPacketCapture().\n\n        Args:\n           dev: a TrafficControlledDevice.\n\n        Returns:\n           The HTTP URL for the pcap file or empty string.\n        ' #NEWLINE# self . logger . info ( 'Request stopPacketCapture for ip {0}' . format ( dev . controlledIP ) ) #NEWLINE# self . _cleanup_packet_capture_procs ( ) #NEWLINE# if ( dev . controlledIP in self . ip_to_pcap_proc_map ) : #NEWLINE# #INDENT# p = self . ip_to_pcap_proc_map [ dev . controlledIP ] #NEWLINE# p . terminate ( ) #NEWLINE# max_secs = 5 #NEWLINE# start_time = time . time ( ) #NEWLINE# while ( ( p . poll ( ) is None ) and ( ( time . time ( ) - start_time ) < max_secs ) ) : #NEWLINE# #INDENT# time . sleep ( 0.5 ) #NEWLINE# #UNINDENT# if ( p . poll ( ) is None ) : #NEWLINE# #INDENT# p . kill ( ) #NEWLINE# #UNINDENT# p . pcap . file . bytes = self . _pcap_file_size ( p . pcap . file . name ) #NEWLINE# return p . pcap #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise PacketCaptureException ( message = 'No capture proc for given ipaddr' )