Miroca_Server

This commit is contained in:
Victor Alexandrovich Tsyrenschikov
2026-01-02 00:07:37 +05:00
parent 7ab28ed366
commit c9ae31bc3d
100 changed files with 3108 additions and 0 deletions

44
api/tuya/input_file.py Normal file
View File

@@ -0,0 +1,44 @@
from connect import *
psycopd_file = 'psycopd_con.json'
local_file = 'local_device.json'
tuya_file='tuya_con.json'
def file_base():
try:
cursor=connect_base().cursor()
cursor.execute('SELECT * FROM upanel_device')
except Exception as e:
with open(psycopd_file, 'w', encoding='utf-8') as f:
json.dump({'error': str(e)}, f)
else:
with open(psycopd_file, 'w', encoding='utf-8') as f:
json.dump({v[0]:v[1:] for k,v in enumerate(cursor.fetchall())}, f,
ensure_ascii=False, indent=4)
def file_local():
try:
with open(local_file, 'w', encoding='utf-8') as f:
json.dump(connect_local(), f, ensure_ascii=False, indent=4)
except Exception as e:
with open(local_file, 'w', encoding='utf-8') as f:
json.dump({'error': str(e)}, f)
def file_tuya():
try:
with open(local_file, 'r', encoding='utf-8') as f:
local_device = json.load(f)
with open(tuya_file, 'w', encoding='utf-8') as f:
json.dump([connect_tuya().get(f"/v1.0/iot-03/devices/{local_device[dev]['id']}")
for dev in local_device],f,ensure_ascii=False, indent=4)
except Exception as e:
with open(tuya_file, 'w', encoding='utf-8') as f:
json.dump({'error': str(e)}, f)
if __name__ == '__main__':
file_base()
file_local()
file_tuya()