Client.py - Manual - IIH SDK - Industrial Edge - IIH Software Suite

IIH SDK Documentation

Product
IIH SDK
Product Version
v1.00
Edition
12/2024
Language
en-US (original)
import sys
import logging
import paho.mqtt.client as mqtt
import os
from utils.environment import get_env
from utils.constants import DEV, PROD, LOCALHOST


def assert_ret_(ret):
    if isinstance(ret, Exception):
        template = "Error: An exception of type {0} occurred. Arguments:\n{1!r}"
        message = template.format(type(ret).__name__, ret.args)
        print(message) #writing to the diagnostics
        sys.exit(-1)

class DatabusClient:
    def __init__(self, host="ie-databus", port=1883):
        self.host = host
        if get_env() == DEV:
            self.host = LOCALHOST
        self.port = port
        self.username = "edge"
        self.password = "edge"
        self.is_auth = False
        self.on_connect_callback = None
        self.on_messgae_callback = None
        self._create()