This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
lijia-tsg-oam/py_test/parse_json.py
2019-07-26 21:34:42 +08:00

22 lines
419 B
Python

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()