awx-perfermance/main.py

42 lines
1.3 KiB
Python
Raw Normal View History

2023-09-25 01:28:51 +00:00
# import paho.mqtt.client as mqtt
2023-09-11 02:23:00 +00:00
import json
import argparse
from datetime import datetime
import time
import yaml
parser = argparse.ArgumentParser()
parser.add_argument('-config',help='')
args = parser.parse_args()
with open(f'/usr/local/sdt/app/{args.config}/config.yaml', encoding='UTF-8') as f:
yamlData = yaml.load(f, Loader=yaml.FullLoader)
2023-09-25 01:20:46 +00:00
# mqttc = mqtt.Client() # puclisher 이름
# mqttc.username_pw_set("sdt", "251327")
# mqttc.connect("13.209.39.139", 32259)
2023-10-12 00:44:38 +00:00
f = open(f'/usr/local/sdt/app/{args.config}/text.txt')
# f = open(f'./text.txt', 'w')
2023-09-11 02:23:00 +00:00
while True:
2023-10-12 00:44:38 +00:00
f.write(f"Config value: {yamlData['topic']} \n")
# print(f"Config value: {yamlData['topic']}")
2023-09-25 01:20:46 +00:00
# dataList = []
# for n in range(10):
# data = {
# "timestamp": datetime.now().timestamp(),
# "data": [1 ,2 ,3 ,4 ,5 ,6 ,1, 1, 2, 3, 1 ,2 ,3 ,4 ,5 ,6 ,1, 1, 2, 3, 1 ,2 ,3 ,4 ,5 ,6 ,1, 1, 2, 3, 1 ,2 ,3 ,4 ,5 ,6 ,1, 1, 2, 3, 1 ,2 ,3 ,4 ,5 ,6 ,1, 1, 2, 3, 1 ,2 ,3 ,4 ,5 ,6 ,1, 1, 2, 3, 4, 5, 6, 1],
# }
# dataList.append(data)
time.sleep(2)
# datas = json.dumps({
# "assetCode":"",
# "timestamp":0,
# "dataType":"",
# "data": dataList
# })
# mqttc.publish(f"/device-test/{yamlData['topic']}", datas) # topic, message