summaryrefslogtreecommitdiff
path: root/py_test/parse_json.py
diff options
context:
space:
mode:
Diffstat (limited to 'py_test/parse_json.py')
-rw-r--r--py_test/parse_json.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/py_test/parse_json.py b/py_test/parse_json.py
new file mode 100644
index 0000000..e0bf4f3
--- /dev/null
+++ b/py_test/parse_json.py
@@ -0,0 +1,21 @@
+import json
+
+SN_JSON_PATH = '/opt/tsg/etc/tsg_sn.json'
+
+def tsg_get_sn():
+ try:
+ with open(SN_JSON_PATH) as json_fp:
+ json_dict = json.load(json_fp)
+ return json_dict['sn']
+ except IOError:
+ return ""
+
+def main():
+ sn = tsg_get_sn()
+ if len(sn) > 0:
+ print("%s" %(sn))
+ else:
+ print("can't get sn")
+
+if __name__ == '__main__':
+ main()