From 282f4256e0b978545cde80e849e6ec09b3d04a8e Mon Sep 17 00:00:00 2001 From: whitequark Date: Mon, 26 Jun 2017 03:22:14 +0000 Subject: [PATCH] artiq_pcap: atomically replace pcap file. Otherwise this segfaults Wireshark (?!). --- artiq/frontend/artiq_pcap.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/artiq/frontend/artiq_pcap.py b/artiq/frontend/artiq_pcap.py index 8ec01fc00..66b39683b 100644 --- a/artiq/frontend/artiq_pcap.py +++ b/artiq/frontend/artiq_pcap.py @@ -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))