from subprocess import Popen, PIPE
import re
cmd = Popen('ping -q -c 3 192.0.2.1'.split(' '), stdout=PIPE)
output = cmd.communicate()[0]
match = re.search(
    '(\\d+\\.\\d+)\\/(\\d+\\.\\d+)\\/(\\d+\\.\\d+)\\/(\\d+\\.\\d+)\\s+ms',
    output)
if not match is None:
    print('Average %0.3f' % float(match.group(1)))
else:
    print('Failure')
Scapy how get ping time?