Home | History | Annotate | Line # | Download | only in dnstap
      1 # Copyright (C) Internet Systems Consortium, Inc. ("ISC")
      2 #
      3 # SPDX-License-Identifier: MPL-2.0
      4 #
      5 # This Source Code Form is subject to the terms of the Mozilla Public
      6 # License, v. 2.0.  If a copy of the MPL was not distributed with this
      7 # file, you can obtain one at https://mozilla.org/MPL/2.0/.
      8 #
      9 # See the COPYRIGHT file distributed with this work for additional
     10 # information regarding copyright ownership.
     11 
     12 import sys
     13 
     14 try:
     15     import yaml
     16 except (ModuleNotFoundError, ImportError):
     17     print("No python yaml module, skipping")
     18     sys.exit(1)
     19 
     20 import subprocess
     21 import pprint
     22 
     23 DNSTAP_READ = sys.argv[1]
     24 DATAFILE = sys.argv[2]
     25 ARGS = [DNSTAP_READ, "-y", DATAFILE]
     26 
     27 with subprocess.Popen(ARGS, stdout=subprocess.PIPE) as f:
     28     for y in yaml.load_all(f.stdout, Loader=yaml.SafeLoader):
     29         pprint.pprint(y)
     30