Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
2.9 kB
2
Indexable
Never
import sqlite3
import os
import zeep
import secrets
import json
import time
from loguru import logger

# %% Connect to IntegrationService
credentials = ("школа", "Parsec", "12345")
client = zeep.Client("http://172.16.16.5:10101/IntegrationService/IntegrationService.asmx?WSDL")
# print(client.service.GetVersion())
session = client.service.OpenSession(*credentials)
sessionId = session.Value.SessionID

base = sqlite3.connect('baza.db', check_same_thread=True)
cur = base.cursor()
base.execute('CREATE TABLE IF NOT EXISTS data(last_name,first_name,middle_name,id PRIMARY KEY,id_parents)')
base.commit()

clear = lambda: os.system('cls')

red = "\u001b[31;1m"
gr = "\u001b[32m"
ye = "\u001b[33;1m"

guests = []




def count():
    global guests
    if len(guests) > 10:
        guests.pop(-1)
    # for i in guests:
    #     print(guests[i])
    return guests


while True:
    data = (client.service.GetHardwareEventsResolved(sessionId, 0))

    for i in range(len(data)):
        data2 = (data[i])
        data3 = json.loads(data2)
        if data3['User']['Raw'] == "00000000-0000-0000-0000-000000000000":
            continue

        if data3['User']['Resolved']:
            data4 = (data3['Date'], data3['User']['Resolved'], data3['Component']['Resolved'], data3['User']['Raw'])
            guests.append(data4)
            guests.insert(0, data4)
            count()
        
    print()
    print()
    for i in range(25):
        guests2 = (guests[i])
        logger.info(f'{gr}{guests2[0]} {red}{guests2[1]} {gr}{guests2[2]}')
        # print(guests2[0],guests2[1],guests2[2])
    time.sleep(5)
    clear()

# data2 = (data[41])
# data3 = json.loads(data2)
# print(data3['Date'], "|", data3['User']['Resolved'], "|", data3['Component']['Resolved'], "|", data3['User']['Raw'])
# ba = cur.execute('SELECT * FROM data WHERE id == ?', (data3['User']['Raw'],)).fetchall()
# print(ba)
# for i in range(len(data)):
#     data2 = (data[i])
#     data3 = json.loads(data2)
#     if data3['User']['Resolved']:
#         if (data3['Component']['Raw'] == "7d41863e-1836-4319-9439-7fca7dae24f7" or
#                 data3['Component']['Raw'] == "6f5a2a3e-e802-4048-90de-fd6829b7f177" or
#                 data3['Component']['Raw'] == "c2b73d4f-c793-4dc4-b2e5-e6ffe506edc1" or
#                 data3['Component']['Raw'] == "955cf25f-8119-4a75-a6f7-2317ac868faa"):
#             # print(data3['Date'], "|", data3['User']['Resolved'], "|", data3['Component']['Resolved'], "|", data3['User']['Raw'])
#             print(data3['Date'], "|", data3['User']['Resolved'], "|", data3['Component']['Resolved'])
#             # print(data3['Date'], "|", data3['Component']['Raw'], "|", data3['Component']['Resolved'])
#     else:
#         continue


# data2=(data[-1])
# # print(data2)
# data3 = json.loads(data2)
# print(data3['Date'],"|",data3['Component']['Resolved'],"|",data3['User']['Resolved'],"|",data3['User']['Raw'])



Leave a Comment