artiq_pcap: atomically replace pcap file.

Otherwise this segfaults Wireshark (?!).
This commit is contained in:
whitequark 2017-06-26 03:22:14 +00:00
parent d6f4f1f3bc
commit 282f4256e0
1 changed files with 4 additions and 2 deletions

View File

@ -5,6 +5,7 @@
# use # setcap cap_net_raw+eip /usr/sbin/tcpdump
import argparse
import os
import subprocess
from artiq.tools import verbosity_args, init_logger, logger, SSHClient
@ -27,7 +28,7 @@ def get_argparser():
help="Location to retrieve the pcap file into")
parser.add_argument("command", metavar="COMMAND",
type=str, default=[], nargs="+",
type=str, default=[], nargs=argparse.REMAINDER,
help="command to execute while capturing")
return parser
@ -52,5 +53,6 @@ def main():
tcpdump.close()
sftp.get("{tmp}/trace.pcap".format(tmp=client.tmp),
args.file)
args.file + ".new")
os.rename(args.file + ".new", args.file)
logger.info("Pcap file {file} retrieved".format(file=args.file))