Fix connections

This commit is contained in:
ashatora
2024-05-21 19:21:35 +03:00
parent 6a6ab2239c
commit 4885bc05e4
5 changed files with 45 additions and 188 deletions

View File

@@ -16,8 +16,6 @@ import zlib
import os.path
import requests
from pika.channel import Channel
from .reqs_graphql import get_catalog, get_object
from pygost import gost34112012256
import xml.etree.ElementTree as ET
from .reqs.request_xml_service import RequestXmlService
@@ -160,9 +158,9 @@ def put_object(params, files, url):
key = uuid4().hex
fileVal.fileName = variantToString(item.relative_to(dir.name))
fileVal.key = variantToString(key)
fileVal.bucket = variantToString(Config.s3_bucket)
fileVal.bucket = variantToString(Config.s3_bucket_itv)
res &= feature.addAttribute('c1000', variantFromFileValue(fileVal))
upload_file(str(item), key, Config.s3_bucket)
upload_file(str(item), key, Config.s3_bucket_itv)
ws.transaction()
res = ws.save()
@@ -198,12 +196,22 @@ def onDelivered(params, files, callback_url):
def bnd_connected(bnd_name: str):
global channel_send
logger.warning(f'{bnd_name} connected')
channel_send.basic_publish(exchange=Config.rabbit_status_queue, body=json.dumps({
'bnd_name': bnd_name,
'status': 'connected'
}))
connected.add(bnd_name)
def bnd_disconnected(bnd_name: str):
global channel_send
logger.warning(f'{bnd_name} disconnected')
channel_send.basic_publish(exchange=Config.rabbit_status_queue, body=json.dumps({
'bnd_name': bnd_name,
'status': 'disconnected'
}))
if bnd_name in connected:
connected.remove(bnd_name)