add tsg_sn_update.py, tsg_monit_device.py
This commit is contained in:
21
py_test/parse_json.py
Normal file
21
py_test/parse_json.py
Normal file
@@ -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()
|
||||
Reference in New Issue
Block a user