packdump.py 623 B

123456789101112131415161718192021222324252627282930
  1. # -*- coding: utf-8 -*-
  2. """
  3. Simple script to dump the contents of msgpack files to the terminal
  4. """
  5. # pylint: disable=resource-leakage
  6. # Import python libs
  7. from __future__ import absolute_import, print_function
  8. import os
  9. import pprint
  10. import sys
  11. # Import Salt libs
  12. import salt.utils.msgpack
  13. def dump(path):
  14. """
  15. Read in a path and dump the contents to the screen
  16. """
  17. if not os.path.isfile(path):
  18. print("Not a file")
  19. return
  20. with open(path, "rb") as fp_:
  21. data = salt.utils.msgpack.loads(fp_.read())
  22. pprint.pprint(data)
  23. if __name__ == "__main__":
  24. dump(sys.argv[1])