Make pip buildable
This package would be very useful if able to be built with pip. This
commit makes libcper usable from python with
git clone git@github.com:openbmc/libcper.git
pip install libcper
The API at the moment is primitive, and only supports the parse api. An
example of its usage is included.
Change-Id: I944565c71f616735a738bcc4f815d25251ed27bb
Signed-off-by: Ed Tanous <etanous@nvidia.com>
diff --git a/parse_example.py b/parse_example.py
new file mode 100755
index 0000000..3760b35
--- /dev/null
+++ b/parse_example.py
@@ -0,0 +1,40 @@
+#!/usr/bin/env python3
+
+import json
+
+import cper
+
+
+def main():
+ cper_raw = (
+ b"\x43\x50\x45\x52\x01\x01\xff\xff\xff\xff\x01\x00\x03"
+ b"\x00\x00\x00\x00\x00\x00\x00\x28\x01\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x78"
+ b"\xe4\x01\xa9\x73\x11\xef\x11\x96\xa8\x5f\xa6\xbe\xf5"
+ b"\xee\xa4\xac\xd5\xa9\x09\x04\x52\x14\x42\x96\xe5\x94"
+ b"\x99\x2e\x75\x2b\xcd\x00\x00\x00\x00\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc8\x00"
+ b"\x00\x00\x60\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00"
+ b"\x00\xf2\x44\x52\x6d\x12\x27\xec\x11\xbe\xa7\xcb\x3f"
+ b"\xdb\x95\xc7\x86\x4a\x33\x4f\xcc\x63\xc5\xeb\x11\x8f"
+ b"\x88\x9f\x7a\xc7\x6c\x6f\x0c\x03\x00\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\x00\x44\x52\x41\x4d\x2d\x43\x48\x41"
+ b"\x4e\x4e\x45\x4c\x53\x00\x00\x00\x00\x20\x00\x00\x03"
+ b"\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\xbe"
+ b"\x02\x04\x00\x00\x00\x00\xff\xff\xff\xff\x00\x00\x00"
+ b"\x00\x04\xbe\x02\x04\x00\x10\x00\x00\xff\xff\xff\xff"
+ b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ )
+
+ result = cper.parse(cper_raw)
+ print(json.dumps(result, indent=4))
+
+
+if __name__ == "__main__":
+ main()