Skip to main content

fzutility is a package that provides various utilities for python programming.

Project description

Funzin VC solution team Utils packages

How to use

Logger

To use the logger package, follow these steps:

  1. Import the logger module:

    from fzutility import logger
    
  2. Create a Logger object in class:

    @logger.logger_decorator(level="DEBUG", save_path="logs")
    class template:
        def __init__(self):
            self.logger.debug("This is a debug message")
            self.logger.info("This is an info message")
            self.logger.warning("This is a warning message")
            self.logger.error("This is an error message")
            self.logger.critical("This is a critical message")
        ...
    
    if __name__=="__main__":
        t = template()
    
    @logger.logger_decorator(level="DEBUG", save_path="logs")
    def template(logger, src):
        self.logger.debug("This is a debug message")
        self.logger.info("This is an info message")
        self.logger.warning("This is a warning message")
        self.logger.error("This is an error message")
        self.logger.critical("This is a critical message")
    

MQTT

This module provides a MQTT client implementation. follow these steps:

  1. Import the mqtt client module:

    from fzutility.mqttclient import MqttClient
    
  2. Create a MqttClient object in class:

    config = {
        "mqtt": {
            "broker_id": "your_broker_id"
            "broker_passwd": "your_broker_pw"
            "broker_ip": "your_broker_ip"
            "broker_port": 1883
            "qos": 0
            "pub_topic": "your_publish_topic_name"
            "sub_topic": "your_subscribe_topic_name"
        }
    }
    self.pub_mqtt = MqttClient(
            broker_id=opt["mqtt"]["broker_id"],
            broker_pw=opt["mqtt"]["broker_passwd"],
            host=opt["mqtt"]["broker_ip"],
            port=opt["mqtt"]["broker_port"],
            sub_topic=None,
            qos=opt["mqtt"]["qos"],
        )
    self.sub_mqtt = MqttClient(
        broker_id=opt["mqtt"]["broker_id"],
        broker_pw=opt["mqtt"]["broker_passwd"],
        host=opt["mqtt"]["broker_ip"],
        port=opt["mqtt"]["broker_port"],
        sub_topic=opt["mqtt"]["sub_topic"],
        qos=opt["mqtt"]["qos"],
    )
    
  3. Publish message

    self.pub_mqtt.pub_message(topic=self.pub_topic, msg=msg)
    
  4. Subscribe message

    import threading
    
    subscriber_th = threading.Thread(target=self.sub_mqtt.sub_message, daemon=True)
    subscriber_th.start()
    

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fzutility-1.0.6-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file fzutility-1.0.6-py3-none-any.whl.

File metadata

  • Download URL: fzutility-1.0.6-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.5

File hashes

Hashes for fzutility-1.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 e4b978964de35ef4e051df43b27bf9dcd1b8a1e9e1c8bfcea3a16db5109964ed
MD5 a9c381ef58a865cdc3ac7965e67e0153
BLAKE2b-256 09bd2d730d3534998b3c5ecd3ff69c87639ec4fd13127b90076dcd314a099c74

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page