summaryrefslogtreecommitdiff
path: root/py_test/parse_json.py
blob: e0bf4f3ec5b4c0520c02d77ceb65f86e92f1f34f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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()