From d49811608e99a60f1a6e6c082b74665c6cbfa6ef Mon Sep 17 00:00:00 2001 From: Shuotian Cheng Date: Thu, 9 Feb 2017 18:42:47 -0800 Subject: [PATCH] [platform-detect]: Add script to print out HwSku --- bin/platform-detect | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 bin/platform-detect diff --git a/bin/platform-detect b/bin/platform-detect new file mode 100755 index 0000000000..d0fb5a2c2c --- /dev/null +++ b/bin/platform-detect @@ -0,0 +1,29 @@ +#! /usr/bin/python + +#------------------------------------------------------------------------------ +# # Copyright 2017 Microsoft Corporate all rights reserved +#------------------------------------------------------------------------------ +# +# Determines the embedded platform and returns a string with the model name. +# + +import sys +import xml.etree.ElementTree as ET + +MINIMAP_GRAPH = "/etc/ssw/minigraph.xml" + +def main(): + try: + tree = ET.parse(MINIMAP_GRAPH) + root = tree.getroot() + + print root.find('{Microsoft.Search.Autopilot.Evolution}HwSku').text + + except: + print "UNKNOWN" + return 1 + + return 0 + +if __name__ == "__main__": + sys.exit(main())