Commit 8f014f81 by arjun.b

topic updated

parent 3650e464
import configparser
from scripts.logging.logging import logger
try:
config = configparser.ConfigParser()
......@@ -14,4 +13,4 @@ try:
redis_port = config.get("redis_connect", "port")
file_name = config.get("logging", "file_name")
except configparser.NoOptionError:
logger.error("could not find conf file")
print("could not ")
......@@ -3,11 +3,12 @@ import logging
import redis
from scripts.config.application_config import redis_host, redis_port
from scripts.logging.logging import logger
try:
# Connect to Redis
r = redis.Redis(host=redis_host, port=int(redis_port), db=1)
except Exception as e:
logging.error(f'cant connect to redis {e}')
logger.error(f'cant connect to redis {e}')
print(str(e))
......@@ -7,7 +7,7 @@ from scripts.logging.logging import logger
broker = hostname
port = int(port_num)
topic = topic_name
# topic = topic_name
client = mqtt_client.Client()
client.connect(broker, port, 60)
......@@ -30,6 +30,7 @@ def assign_patient(patient, doctors):
# Assign the patient to the next doctor
patient.update({"doctor": next_doctor})
r.hset(patient['patient_id'], 'doctor', next_doctor)
topic=f"hospital/{next_doctor}"
client.publish(topic, json.dumps(patient))
except Exception as e:
logger.error(f"could not assign patient: {e}")
import logging
from scripts.config.redis_connection import r
from scripts.logging.logging import logger
def get_next_doctor(doctors):
......@@ -13,4 +14,4 @@ def get_next_doctor(doctors):
# Return the next doctor
return doctors[current_doctor]
except Exception as e:
logging.error(f'cant find next doctor:{e}')
logger.error(f'cant find next doctor:{e}')
import logging
from fastapi import FastAPI
from scripts.core.handlers.publisher_handler import PublishHandler
from scripts.logging.logging import logger
from scripts.model.patients import patients
from scripts.constants.end_points import EndPoints
app = FastAPI()
......@@ -16,5 +16,5 @@ def publish_data(details: patients):
try:
PublishHandler.main_handler(details)
except Exception as e:
logging.error(f'assign a doctor and publishing the details failed: {e}')
logger.error(f'assign a doctor and publishing the details failed: {e}')
return {"data": "data published"}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment