Skip to main content

Common tools of AI module for BNQ

Project description

打包和上传

使用以下命令来生成和上传分发包:

python setup.py sdist bdist_wheel
twine upload dist/*

类说明

1. NacConnect

用于连接 Nacos 服务,获取配置文件信息。

参数信息

  • server_addresses:地址
  • namespace:命名空间
  • username:用户名
  • password:密码
  • group:组合字典,包括 group_namedata_ids
  • conf_type:配置文件类型,非必需,值为 jsonyaml

示例

from bnq_py_core import NacConnect

test_data = {
    'group': {'t-dev': ['project_name_1', 'project_name_2']},
    'username': 'nacos',
    'password': 'nacos',
    'server_addresses': '127.0.0.1:8080',
    'namespace': 't-dev'
}
conf_test = NacConnect(**test_data)
print(conf_test())

2. LoggingRecord

用于记录日志信息。

参数信息

  • max_bytes:日志文件最大大小,默认值 20M
  • backup_count:日志备份最大数量,默认值为 10
  • log_level:日志级别,默认值为 INFO
  • log_dir:日志文件路径,默认在根目录下创建 log 文件夹

示例

import logging

from bnq_py_core import LoggingRecord

testLog = LoggingRecord(log_level=logging.DEBUG)
for i in range(10):
    print(i, 'i')
    print(testLog, "testLog")
    testLog.debug(i)
    testLog.info("中文测试")
    testLog.error(i)
    testLog.warning(i)
    testLog.exception(i)

3. LoggingRecordTimeRotation

用于记录日志信息, 可根据设定时间自动轮转日志文件。

参数信息

  • max_bytes:日志文件最大大小,默认值 20M
  • backup_count:日志备份最大数量,默认值为 10
  • log_level:日志级别,默认值为 INFO
  • log_dir:日志文件路径,默认在根目录下创建 log 文件夹

示例

import logging

from bnq_py_core import LoggingRecordTimeRotation

testLog = LoggingRecordTimeRotation(log_level=logging.DEBUG)
for i in range(10):
    print(i, 'i')
    print(testLog, "testLog")
    testLog.debug(i)
    testLog.info("中文测试")
    testLog.error(i)
    testLog.warning(i)
    testLog.exception(i)

4. SingletonMeta

用于实现单例模式。

示例

from bnq_py_core import SingletonMeta


class TestClass(metaclass=SingletonMeta):
    def __init__(self):
        pass

5. CosConnect

用于连接腾讯云存储平台 COS。

参数信息

  • secret_id:腾讯云 secret_id
  • secret_key:腾讯云 secret_key
  • region:腾讯云存储区域

示例

from bnq_py_core import CosConnect

test_data = {
    'secret_id': 'AKIDxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
    'secret_key': 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
    'region': 'ap-guangzhou'
}
cos_test = CosConnect(**test_data)

Project details


Download files

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

Source Distribution

common-tools-ai-bnq-0.2.0.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

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

common_tools_ai_bnq-0.2.0-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file common-tools-ai-bnq-0.2.0.tar.gz.

File metadata

  • Download URL: common-tools-ai-bnq-0.2.0.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.8

File hashes

Hashes for common-tools-ai-bnq-0.2.0.tar.gz
Algorithm Hash digest
SHA256 35a1a48989a201dce6e9ba689b802af2dbb80a7b2d8123e184753f63e3a4d78a
MD5 51f076eebc5e26d7dc12fe3833a79a47
BLAKE2b-256 a9c764c0bc8320dadc4d4edaad4fa756aa85506444e302c80e603a3318a45b21

See more details on using hashes here.

File details

Details for the file common_tools_ai_bnq-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for common_tools_ai_bnq-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3b88c9518f0cffe17be130e2992e371bb0d88a0ec5eda2bca6b33e04dc8faf77
MD5 5ea03e64ed8ef47380eb72f939dcffa7
BLAKE2b-256 39249f8bfae5b01765b218ed93b98e55845ba92bd5bec2e2575c5633c13ffa0f

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