2020-04-02 20:10:20 -05:00
|
|
|
"""
|
2014-03-20 14:31:26 -06: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
|
|
|
|
2014-03-20 14:31:26 -06:00
|
|
|
import os
|
|
|
|
import pprint
|
|
|
|
import sys
|
|
|
|
|
2018-11-27 21:31:28 +01:00
|
|
|
import salt.utils.msgpack
|
2014-03-20 14:31:26 -06:00
|
|
|
|
|
|
|
|
|
|
|
def dump(path):
|
2020-04-02 20:10:20 -05:00
|
|
|
"""
|
2014-03-20 14:31:26 -06:00
|
|
|
Read in a path and dump the contents to the screen
|
2020-04-02 20:10:20 -05:00
|
|
|
"""
|
2014-03-20 14:31:26 -06:00
|
|
|
if not os.path.isfile(path):
|
2014-11-24 03:03:48 +00:00
|
|
|
print("Not a file")
|
2014-03-20 14:31:26 -06:00
|
|
|
return
|
|
|
|
with open(path, "rb") as fp_:
|
2018-11-27 21:31:28 +01:00
|
|
|
data = salt.utils.msgpack.loads(fp_.read())
|
2014-03-20 14:31:26 -06:00
|
|
|
pprint.pprint(data)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
dump(sys.argv[1])
|