salt/tests/packdump.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

28 lines
505 B
Python
Raw Normal View History

2020-04-02 20:10:20 -05:00
"""
Simple script to dump the contents of msgpack files to the terminal
2020-04-02 20:10:20 -05:00
"""
2024-02-27 10:24:22 +00:00
2017-04-04 13:11:54 +01:00
# pylint: disable=resource-leakage
2020-04-02 20:10:20 -05:00
import os
import pprint
import sys
import salt.utils.msgpack
def dump(path):
2020-04-02 20:10:20 -05:00
"""
Read in a path and dump the contents to the screen
2020-04-02 20:10:20 -05:00
"""
if not os.path.isfile(path):
2014-11-24 03:03:48 +00:00
print("Not a file")
return
with open(path, "rb") as fp_:
data = salt.utils.msgpack.loads(fp_.read())
pprint.pprint(data)
if __name__ == "__main__":
dump(sys.argv[1])